@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
96 lines (95 loc) • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConflictError = exports.NotFoundError = exports.SerializationError = exports.InternalError = exports.ValidationError = exports.BaseError = void 0;
/**
* @summary Base Error
*
* @param {string} msg the error message
*
* @class BaseDLTError
* @extends Error
*/
class BaseError extends Error {
constructor(name, msg) {
if (msg instanceof BaseError)
return msg;
const message = `[${name}] ${msg instanceof Error ? msg.message : msg}`;
super(message);
if (msg instanceof Error)
this.stack = msg.stack;
}
}
exports.BaseError = BaseError;
/**
* @summary Represents a failure in the Model details
*
* @param {string} msg the error message
*
* @class ValidationError
* @extends BaseError
*/
class ValidationError extends BaseError {
constructor(msg) {
super(ValidationError.name, msg);
}
}
exports.ValidationError = ValidationError;
/**
* @summary Represents an internal failure (should mean an error in code)
*
* @param {string} msg the error message
*
* @class InternalError
* @extends BaseError
*/
class InternalError extends BaseError {
constructor(msg) {
super(InternalError.name, msg);
}
}
exports.InternalError = InternalError;
/**
* @summary Represents a failure in the Model de/serialization
*
* @param {string} msg the error message
*
* @class SerializationError
* @extends BaseError
*
*/
class SerializationError extends BaseError {
constructor(msg) {
super(SerializationError.name, msg);
}
}
exports.SerializationError = SerializationError;
/**
* @summary Represents a failure in finding a model
*
* @param {string} msg the error message
*
* @class NotFoundError
* @extends BaseError
*
*/
class NotFoundError extends BaseError {
constructor(msg) {
super(NotFoundError.name, msg);
}
}
exports.NotFoundError = NotFoundError;
/**
* @summary Represents a conflict in the storage
*
* @param {string} msg the error message
*
* @class ConflictError
* @extends BaseError
*
*/
class ConflictError extends BaseError {
constructor(msg) {
super(ConflictError.name, msg);
}
}
exports.ConflictError = ConflictError;