jhipster-rasha-core
Version:
JHipster's own domain language and core objects
46 lines (41 loc) • 954 B
JavaScript
;
/**
* This constant is where all the error cases go.
* No need to assign anything to the keys, the following loop will take care of
* that.
*/
const EXCEPTIONS = {
Assertion: null,
FileNotFound: null,
IllegalArgument: null,
IllegalAssociation: null,
IllegalName: null,
InvalidObject: null,
MalformedAssociation: null,
NoSQLModeling: null,
NullPointer: null,
UndeclaredEntity: null,
UnsupportedOperation: null,
WrongAssociation: null,
WrongFile: null,
WrongDir: null,
WrongType: null,
WrongValidation: null
};
for (let key in EXCEPTIONS) {
if (EXCEPTIONS.hasOwnProperty(key)) {
EXCEPTIONS[key] = key;
}
}
module.exports = {
exceptions: EXCEPTIONS,
buildException: buildException
};
function buildException(name, message) {
const exception = {
name: name ? `${name}Exception` : 'Exception',
message: (message || '')
};
exception.prototype = new Error();
return exception;
}