@iamcalegari/mongoat / MongoatError
Class: MongoatError
Defined in: src/errors/index.ts:22
Base error class for all errors raised by Mongoat itself (config conflicts, missing connection, missing dbName, etc.).
Extends the native Error and preserves an optional cause (the original error, if any) so consumers can inspect the root cause without losing the original stack trace.
Every MongoatError (and subclass) carries a stable code string — the dev programs against .code, independent of .message (which can change without breaking semver). Defaults to 'MONGOAT_ERROR' for the base class; each subclass below overrides its own default.
Subclasses let the dev discriminate the error kind via instanceof:
MongoatValidationError— schema/ObjectId/filtro inválido.MongoatConnectionError— sem conexão / dbName ausente.MongoatDriverError— wrap sanitizado de um erro do driver.
Extends
Error
Extended by
Constructors
Constructor
new MongoatError(
message,options?):MongoatError
Defined in: src/errors/index.ts:40
Parameters
message
string
options?
cause?
unknown
code?
string
Returns
MongoatError
Overrides
Error.constructor
Properties
code
readonlycode:string
Defined in: src/errors/index.ts:23
suppressed?
optionalsuppressed?:unknown[]
Defined in: src/errors/index.ts:38
Errors from secondary, best-effort operations that failed while this error was being handled — never the primary cause of failure. Absent (undefined) unless at least one secondary failure was recorded; the array can accumulate more than one entry across a single error's lifecycle.
Each entry is the raw error captured from the secondary operation, not sanitized. Never serialize a MongoatError (or this field alone) with JSON.stringify — the same discipline already applied to .cause.