Closed Quelklef closed 5 months ago
Thanks for the suggestion!
But I don't know if it's worth it... what would be gained, the Error.code
property? That's already deprecated and I'm not sure if anyone uses it for IndexedDB. Anything else?
If there's a compelling use case, then yes please go for it. And also in src/test/web-platform-tests/wpt-env.js replace global.DOMException = Error;
with importing that module to the global scope.
My current use-case is code that looks like the following:
try {
await doDbOperation();
} catch (err) {
if (err instanceof DOMException && err.name === 'NotFoundError') {
throw new MyErrorWrapper('message');
} else {
throw err;
}
}
Cool, I'll see what I can do.
Yeah that makes sense, I'd accept a PR :)
fake-indexeddb currently throws exceptions that are
Error
objects, but IndexedDB throwsDOMException
s.Of course, this is a little sticky 'cause fake-indexeddb is on Node, but there seems to be a well-known
DOMException
polyfill that could be used.Seems like an easy change: just modify
src/lib/errors.ts
, right?. I can try to make a PR with your go-ahead.