app.portBindings and newManifest.tcpPorts may be null
This commit is contained in:
32
src/databaseerror.js
Normal file
32
src/databaseerror.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/* jslint node:true */
|
||||
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = DatabaseError;
|
||||
|
||||
var assert = require('assert'),
|
||||
util = require('util');
|
||||
|
||||
function DatabaseError(reason, errorOrMessage) {
|
||||
assert.strictEqual(typeof reason, 'string');
|
||||
assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined' || errorOrMessage === null);
|
||||
|
||||
Error.call(this);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
|
||||
this.reason = reason;
|
||||
if (typeof errorOrMessage === 'undefined' || errorOrMessage === null) {
|
||||
this.message = reason;
|
||||
} else if (typeof errorOrMessage === 'string') {
|
||||
this.message = errorOrMessage;
|
||||
} else {
|
||||
this.message = 'Internal error';
|
||||
this.nestedError = errorOrMessage;
|
||||
}
|
||||
}
|
||||
util.inherits(DatabaseError, Error);
|
||||
|
||||
DatabaseError.INTERNAL_ERROR = 'Internal error';
|
||||
DatabaseError.ALREADY_EXISTS = 'Entry already exist';
|
||||
DatabaseError.NOT_FOUND = 'Record not found';
|
||||
DatabaseError.BAD_FIELD = 'Invalid field';
|
||||
Reference in New Issue
Block a user