aaronpowell / db.js

db.js is a wrapper for IndexedDB to make it easier to work against
http://aaronpowell.github.com/db.js/
MIT License
818 stars 142 forks source link

Allow for consistent promise use (including for errors), deferring th… #162

Closed brettz9 closed 8 years ago

brettz9 commented 8 years ago

…e error in the case of query preparation until execution

This PR attempts to address item 2 mentioned in the OP of issue #144, i.e., of consistently rejecting in the public API rather than throwing.

Two notes:

  1. Although deferring the reporting of the error may not be ideal (in the case of queries), I think this is necessary given how the chaining does not expect promises until the end, and otherwise the user will need to add try-catch blocks.
  2. I thought it most consistent to turn close into a Promise as with the other Server methods (allowing a user to catch an error if a call to it did not first check isClosed).