Skip to main content
Version: 3.0 Beta

Errors

The ORM throws an ORMError in case of failures. The class has the following fields:

/**
* ZenStack ORM error.
*/
export class ORMError extends Error {
/**
* The name of the model that the error pertains to.
*/
model?: string;

/**
* The error code given by the underlying database driver.
*/
dbErrorCode?: unknown;

/**
* The error message given by the underlying database driver.
*/
dbErrorMessage?: string;

/**
* The reason code for policy rejection. Only available when `reason` is `REJECTED_BY_POLICY`.
*/
rejectedByPolicyReason?: RejectedByPolicyReason;

/**
* The SQL query that was executed. Only available when `reason` is `DB_QUERY_ERROR`.
*/
sql?: string;

/**
* The parameters used in the SQL query. Only available when `reason` is `DB_QUERY_ERROR`.
*/
sqlParams?: readonly unknown[];
}

/**
* Reason code for ORM errors.
*/
export enum ORMErrorReason {
/**
* ORM client configuration error.
*/
CONFIG_ERROR = 'config-error',

/**
* Invalid input error.
*/
INVALID_INPUT = 'invalid-input',

/**
* The specified record was not found.
*/
NOT_FOUND = 'not-found',

/**
* Operation is rejected by access policy.
*/
REJECTED_BY_POLICY = 'rejected-by-policy',

/**
* Error was thrown by the underlying database driver.
*/
DB_QUERY_ERROR = 'db-query-error',

/**
* The requested operation is not supported.
*/
NOT_SUPPORTED = 'not-supported',

/**
* An internal error occurred.
*/
INTERNAL_ERROR = 'internal-error',
}

/**
* Reason code for policy rejection.
*/
export enum RejectedByPolicyReason {
/**
* Rejected because the operation is not allowed by policy.
*/
NO_ACCESS = 'no-access',

/**
* Rejected because the result cannot be read back after mutation due to policy.
*/
CANNOT_READ_BACK = 'cannot-read-back',

/**
* Other reasons.
*/
OTHER = 'other',
}
Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below