Permalink
Browse files

db; refactor handleError

  • Loading branch information...
1 parent 6e657fa commit e46accfcc6164068c7c6a4ad66fe60ef0f9dae8f @aheckmann committed Jan 29, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/db.js
View
@@ -106,9 +106,7 @@ function createConstructor (db) {
;(DB.prototype.open = function (cb) {
db.open(function (err) {
if (err) {
- return cb
- ? cb(err)
- : handleError(err)
+ return handleError(err, cb);
}
if ('function' == typeof cb) {
@@ -229,9 +227,14 @@ function createConstructor (db) {
* Error reporting helper
*/
-function handleError (err) {
+function handleError (err, cb) {
if (err) {
- return console.error(err);
+ if (cb) {
+ return process.nextTick(function(){
+ cb(err);
+ });
+ }
+ console.error(err);
}
}

0 comments on commit e46accf

Please sign in to comment.