@decaf-ts/core
Version:
Core persistence module for the decaf framework
46 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MigrationRuleError = exports.MigrationError = exports.UnsupportedError = void 0;
const db_decorators_1 = require("@decaf-ts/db-decorators");
/**
* @description Error thrown when an unsupported operation is attempted
* @summary This error is thrown when an operation is requested that is not supported by the current
* persistence adapter or configuration. It extends the BaseError class and sets a 500 status code.
* @param {string|Error} msg - The error message or an Error object to wrap
* @class UnsupportedError
* @example
* ```typescript
* // Throwing an UnsupportedError
* if (!adapter.supportsTransactions()) {
* throw new UnsupportedError('Transactions are not supported by this adapter');
* }
*
* // Catching an UnsupportedError
* try {
* await adapter.beginTransaction();
* } catch (error) {
* if (error instanceof UnsupportedError) {
* console.error('Operation not supported:', error.message);
* }
* }
* ```
*/
class UnsupportedError extends db_decorators_1.InternalError {
constructor(msg) {
super(msg, UnsupportedError.name, 500);
}
}
exports.UnsupportedError = UnsupportedError;
class MigrationError extends db_decorators_1.InternalError {
constructor(msg, name = MigrationError.name) {
super(msg, name, 500);
}
}
exports.MigrationError = MigrationError;
class MigrationRuleError extends MigrationError {
constructor(msg) {
super(msg, MigrationRuleError.name);
}
}
exports.MigrationRuleError = MigrationRuleError;
//# sourceMappingURL=errors.js.map