UNPKG

fireodm

Version:

A basic and extensible ODM for the Firestore Admin SDK in Node.js with decorators, relationships, and validation.

43 lines 1.29 kB
/** * Base class for custom ORM errors. */ export 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); } } } /** * Error thrown when Zod validation fails on a model instance. */ export 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; } } /** * Error thrown when a requested Firestore document is not found. */ export 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; } } //# sourceMappingURL=errors.js.map