Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
cb2eaea6
Commit
cb2eaea6
authored
Jun 29, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IndexedDB: provide some informations in the error message
parent
a0c3917a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+15
-8
test/jio.storage/indexeddbstorage.tests.js
test/jio.storage/indexeddbstorage.tests.js
+8
-2
No files found.
src/jio.storage/indexeddbstorage.js
View file @
cb2eaea6
...
@@ -209,14 +209,18 @@
...
@@ -209,14 +209,18 @@
});
});
};
};
function
handleGet
(
request
,
resolve
,
reject
)
{
function
handleGet
(
store
,
id
,
resolve
,
reject
)
{
var
request
=
store
.
get
(
id
);
request
.
onerror
=
reject
;
request
.
onerror
=
reject
;
request
.
onsuccess
=
function
()
{
request
.
onsuccess
=
function
()
{
if
(
request
.
result
)
{
if
(
request
.
result
)
{
resolve
(
request
.
result
);
resolve
(
request
.
result
);
}
else
{
}
else
{
// XXX How to get ID
reject
(
new
jIO
.
util
.
jIOError
(
reject
(
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
));
"
IndexedDB: cannot find object '
"
+
id
+
"
' in the '
"
+
store
.
name
+
"
' store
"
,
404
));
}
}
};
};
}
}
...
@@ -227,7 +231,8 @@
...
@@ -227,7 +231,8 @@
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
transaction
=
openTransaction
(
db
,
[
"
metadata
"
],
"
readonly
"
);
var
transaction
=
openTransaction
(
db
,
[
"
metadata
"
],
"
readonly
"
);
handleGet
(
handleGet
(
transaction
.
objectStore
(
"
metadata
"
).
get
(
id
),
transaction
.
objectStore
(
"
metadata
"
),
id
,
resolve
,
resolve
,
reject
reject
);
);
...
@@ -260,7 +265,8 @@
...
@@ -260,7 +265,8 @@
);
);
}
}
handleGet
(
handleGet
(
transaction
.
objectStore
(
"
metadata
"
).
get
(
id
),
transaction
.
objectStore
(
"
metadata
"
),
id
,
getAttachments
,
getAttachments
,
reject
reject
);
);
...
@@ -388,7 +394,8 @@
...
@@ -388,7 +394,8 @@
result_list
.
push
(
result
);
result_list
.
push
(
result
);
}
}
i
+=
1
;
i
+=
1
;
handleGet
(
store
.
get
(
buildKeyPath
([
id
,
name
,
i
])),
handleGet
(
store
,
buildKeyPath
([
id
,
name
,
i
]),
(
i
<=
end_index
)
?
getPart
(
i
)
:
resolver
,
(
i
<=
end_index
)
?
getPart
(
i
)
:
resolver
,
reject
reject
);
);
...
@@ -397,8 +404,8 @@
...
@@ -397,8 +404,8 @@
getPart
(
start_index
-
1
)();
getPart
(
start_index
-
1
)();
}
}
// XXX Should raise if key is not good
// XXX Should raise if key is not good
handleGet
(
transaction
.
objectStore
(
"
attachment
"
)
handleGet
(
transaction
.
objectStore
(
"
attachment
"
)
,
.
get
(
buildKeyPath
([
id
,
name
])
),
buildKeyPath
([
id
,
name
]
),
getBlob
,
getBlob
,
reject
reject
);
);
...
...
test/jio.storage/indexeddbstorage.tests.js
View file @
cb2eaea6
...
@@ -493,7 +493,10 @@
...
@@ -493,7 +493,10 @@
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document
"
);
equal
(
error
.
message
,
"
IndexedDB: cannot find object 'inexistent' in the 'metadata' store
"
);
equal
(
error
.
status_code
,
404
);
equal
(
error
.
status_code
,
404
);
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
...
@@ -679,7 +682,10 @@
...
@@ -679,7 +682,10 @@
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document
"
);
equal
(
error
.
message
,
"
IndexedDB: cannot find object 'inexistent' in the 'metadata' store
"
);
equal
(
error
.
status_code
,
404
);
equal
(
error
.
status_code
,
404
);
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment