diff --git a/src/apps.js b/src/apps.js index 7b741cc56..53e21f028 100644 --- a/src/apps.js +++ b/src/apps.js @@ -123,9 +123,10 @@ var appdb = require('./appdb.js'), // http://dustinsenos.com/articles/customErrorsInNode // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi -function AppsError(reason, errorOrMessage) { +function AppsError(reason, errorOrMessage, details) { assert.strictEqual(typeof reason, 'string'); assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined'); + assert(typeof details === 'object' || typeof details === 'undefined'); Error.call(this); Error.captureStackTrace(this, this.constructor); @@ -140,6 +141,8 @@ function AppsError(reason, errorOrMessage) { this.message = 'Internal error'; this.nestedError = errorOrMessage; } + + if (details) _.extend(this, details); } util.inherits(AppsError, Error); AppsError.INTERNAL_ERROR = 'Internal Error';