@cerbos/core
Version:
Common types used by the Cerbos client libraries
60 lines • 1.63 kB
TypeScript
import type { ValidationError } from "./types/external";
import { Status } from "./types/external";
/**
* Options for creating an error.
*
* @public
*/
export interface ErrorOptions {
/**
* The original error that caused this one.
*/
cause?: unknown;
}
/**
* Error thrown when the Cerbos policy decision point server returns an unsuccessful response.
*
* @public
*/
export declare class NotOK extends Error {
/**
* The status code returned by the Cerbos policy decision point server.
*/
readonly code: Exclude<Status, Status.OK>;
/**
* Additional error details.
*/
readonly details: string;
/**
* Parse a JSON-serialized unsuccessful response.
*/
static fromJSON(text: string): NotOK;
constructor(
/**
* The status code returned by the Cerbos policy decision point server.
*/
code: Exclude<Status, Status.OK>,
/**
* Additional error details.
*/
details: string, options?: ErrorOptions);
}
/**
* Error thrown when input fails schema validation, if the {@link @cerbos/core#Client} is configured with {@link @cerbos/core#Options.onValidationError | onValidationError} set to `"throw"`.
*
* @public
*/
export declare class ValidationFailed extends Error {
/**
* The validation errors that occurred.
*/
readonly validationErrors: ValidationError[];
constructor(
/**
* The validation errors that occurred.
*/
validationErrors: ValidationError[]);
}
/** @internal */
export declare function _setErrorNameAndStack(error: Error): void;
//# sourceMappingURL=errors.d.ts.map