UNPKG

2.24 kBTypeScriptView Raw
1/**
2 * ```ts
3 * import type { ArangoError, HttpError } from "arangojs/error.js";
4 * ```
5 *
6 * The "error" module provides types and interfaces for TypeScript related
7 * to arangojs error handling.
8 *
9 * @packageDocumentation
10 */
11import { ArangojsResponse } from "./lib/request.js";
12/**
13 * Indicates whether the given value represents an {@link ArangoError}.
14 *
15 * @param error - A value that might be an `ArangoError`.
16 */
17export declare function isArangoError(error: any): error is ArangoError;
18/**
19 * Indicates whether the given value represents an ArangoDB error response.
20 *
21 * @internal
22 */
23export declare function isArangoErrorResponse(body: any): boolean;
24/**
25 * Indicates whether the given value represents a Node.js `SystemError`.
26 */
27export declare function isSystemError(err: any): err is SystemError;
28/**
29 * Interface representing a Node.js `SystemError`.
30 */
31export interface SystemError extends Error {
32 code: string;
33 errno: number | string;
34 syscall: string;
35}
36/**
37 * Represents an error returned by ArangoDB.
38 */
39export declare class ArangoError extends Error {
40 name: string;
41 /**
42 * ArangoDB error code.
43 *
44 * See [ArangoDB error documentation](https://www.arangodb.com/docs/stable/appendix-error-codes.html).
45 */
46 errorNum: number;
47 /**
48 * HTTP status code included in the server error response object.
49 */
50 code: number;
51 /**
52 * Server response object.
53 */
54 response: any;
55 /**
56 * @internal
57 */
58 constructor(response: ArangojsResponse);
59 /**
60 * @internal
61 *
62 * Indicates that this object represents an ArangoDB error.
63 */
64 get isArangoError(): true;
65 toJSON(): {
66 error: boolean;
67 errorMessage: string;
68 errorNum: number;
69 code: number;
70 };
71}
72/**
73 * Represents a plain HTTP error response.
74 */
75export declare class HttpError extends Error {
76 name: string;
77 /**
78 * Server response object.
79 */
80 response: any;
81 /**
82 * HTTP status code of the server response.
83 */
84 code: number;
85 /**
86 * @internal
87 */
88 constructor(response: ArangojsResponse);
89 toJSON(): {
90 error: boolean;
91 code: number;
92 };
93}
94//# sourceMappingURL=error.d.ts.map
\No newline at end of file