I’m trying something like
var store = trans.objectStore("todo");
which gives in the console the following erropr
Uncaught Error: NOT_FOUND_ERR: DOM IDBDatabase Exception 3
Although I expect this error (the object store doesn’t exist) but I want to catch it. I tried to add an onerror to the transaction
trans.onerror = function(e) { ... }
but the onerror is not called. Is there any way to catch this error using onerror? Or is the only way to wrap it with try/catch?
Why do you want to catch that exception? before you call the store, you can check in the database if an object stored with that name exists.
If you want to work with exceptions, it’s bad for performance.