fireodm
Version:
A basic and extensible ODM for the Firestore Admin SDK in Node.js with decorators, relationships, and validation.
49 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotFoundError = exports.ValidationError = exports.OrmError = void 0;
/**
* Base class for custom ORM errors.
*/
class OrmError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name; // Set name to the specific error class
// Maintains proper stack trace in V8 environments (Node.js)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}
exports.OrmError = OrmError;
/**
* Error thrown when Zod validation fails on a model instance.
*/
class ValidationError extends OrmError {
/**
* Creates an instance of ValidationError.
* @param message The error message.
* @param issues An array of Zod validation issues.
*/
constructor(message, issues) {
super(message);
this.issues = issues;
}
}
exports.ValidationError = ValidationError;
/**
* Error thrown when a requested Firestore document is not found.
*/
class NotFoundError extends OrmError {
/**
* Creates an instance of NotFoundError.
* @param modelName The name of the model class.
* @param documentId The ID of the document.
*/
constructor(modelName, documentId) {
super(`Document not found: ${modelName} with ID ${documentId}`);
this.modelName = modelName;
this.documentId = documentId;
}
}
exports.NotFoundError = NotFoundError;
//# sourceMappingURL=errors.js.map