attlaz-client 1.75.0 → 1.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Http/ClientError.d.ts +14 -0
- package/dist/Http/ClientError.js +22 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,20 @@ export declare class ClientError extends Error {
|
|
|
3
3
|
message: string;
|
|
4
4
|
response: unknown;
|
|
5
5
|
constructor(message: string, httpErrorCode?: number | null);
|
|
6
|
+
/**
|
|
7
|
+
* Type guard: true when `error` is a ClientError (or a subclass such as ApiError). Use it to
|
|
8
|
+
* narrow before reading typed fields (`httpStatus`, `message`, …). Relies on instanceof, which
|
|
9
|
+
* is reliable when there's a single copy of this package (e.g. a bundled web app). For a status
|
|
10
|
+
* check that must survive multiple package copies / realm boundaries, prefer statusOf().
|
|
11
|
+
*/
|
|
12
|
+
static is(error: unknown): error is ClientError;
|
|
13
|
+
/**
|
|
14
|
+
* The HTTP status carried by a ClientError/ApiError, or null for anything else (e.g. a plain
|
|
15
|
+
* Error or a non-error value). Robust across module/realm boundaries: when instanceof fails
|
|
16
|
+
* (two copies of this package in one process) it falls back to reading a numeric httpStatus
|
|
17
|
+
* field. This is the safe way to ask "what status did this error carry?".
|
|
18
|
+
*/
|
|
19
|
+
static statusOf(error: unknown): number | null;
|
|
6
20
|
static fromError(error: Error): ClientError;
|
|
7
21
|
static byStatus(statusCode: number, statusText: string): ClientError | null;
|
|
8
22
|
}
|
package/dist/Http/ClientError.js
CHANGED
|
@@ -8,6 +8,28 @@ export class ClientError extends Error {
|
|
|
8
8
|
this.message = message;
|
|
9
9
|
this.httpStatus = httpErrorCode;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard: true when `error` is a ClientError (or a subclass such as ApiError). Use it to
|
|
13
|
+
* narrow before reading typed fields (`httpStatus`, `message`, …). Relies on instanceof, which
|
|
14
|
+
* is reliable when there's a single copy of this package (e.g. a bundled web app). For a status
|
|
15
|
+
* check that must survive multiple package copies / realm boundaries, prefer statusOf().
|
|
16
|
+
*/
|
|
17
|
+
static is(error) {
|
|
18
|
+
return error instanceof ClientError;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The HTTP status carried by a ClientError/ApiError, or null for anything else (e.g. a plain
|
|
22
|
+
* Error or a non-error value). Robust across module/realm boundaries: when instanceof fails
|
|
23
|
+
* (two copies of this package in one process) it falls back to reading a numeric httpStatus
|
|
24
|
+
* field. This is the safe way to ask "what status did this error carry?".
|
|
25
|
+
*/
|
|
26
|
+
static statusOf(error) {
|
|
27
|
+
if (error instanceof ClientError) {
|
|
28
|
+
return error.httpStatus;
|
|
29
|
+
}
|
|
30
|
+
const status = error?.httpStatus;
|
|
31
|
+
return typeof status === 'number' ? status : null;
|
|
32
|
+
}
|
|
11
33
|
static fromError(error) {
|
|
12
34
|
// Already a ClientError (or a subclass such as ApiError) — preserve it as-is.
|
|
13
35
|
if (error instanceof ClientError) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.76.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.76.0";
|