@ima/core
Version:
IMA.js framework for isomorphic javascript application
50 lines (49 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "GenericError", {
enumerable: true,
get: function() {
return GenericError;
}
});
const _Error = require("./Error");
class GenericError extends _Error.IMAError {
_params;
/**
* Initializes the generic IMA error.
*
* @param message The message describing the cause of the error.
* @param params A data map providing additional
* details related to the error. It is recommended to set the
* `status` field to the HTTP response code that should be sent
* to the client.
*/ constructor(message, params){
super(message, params);
/**
* The data providing additional details related to this error.
*/ this._params = params ?? {};
}
/**
* @inheritDoc
*/ getHttpStatus() {
return this._params.status || super.getHttpStatus();
}
/**
* @inheritDoc
*/ getParams() {
return this._params;
}
/**
* @inheritDoc
*/ isClientError() {
return this.getHttpStatus() >= 400 && this.getHttpStatus() < 500;
}
/**
* @inheritDoc
*/ isRedirection() {
return this.getHttpStatus() >= 300 && this.getHttpStatus() < 400;
}
}
//# sourceMappingURL=GenericError.js.map