Skip to content

Commit 2fec367

Browse files
committed
Sub-class the StatusError for errors as pinejs-client-core expects
This fixes the built in retry handler and increase standardization across implementations Update pinejs-client-core from 8.3.2 to 8.4.0 Change-type: patch
1 parent 1d6f979 commit 2fec367

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"typescript": "^5.9.2"
5555
},
5656
"dependencies": {
57-
"pinejs-client-core": "^8.3.2"
57+
"pinejs-client-core": "^8.4.0"
5858
},
5959
"versionist": {
6060
"publishedAt": "2025-10-10T15:02:13.187Z"

src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import type { AnyObject, Resource, AnyResource } from 'pinejs-client-core';
2-
import { PinejsClientCore } from 'pinejs-client-core';
2+
import { PinejsClientCore, StatusError } from 'pinejs-client-core';
33
export type { PinejsClientCore } from 'pinejs-client-core';
44

5-
export class RequestError extends Error {
5+
export class RequestError extends StatusError {
66
public code = 'PineClientFetchRequestError';
7+
public status: number;
78

89
constructor(
9-
public body: string,
10-
public status: number,
11-
public responseHeaders: object,
10+
body: string,
11+
statusCode: number,
12+
public responseHeaders: Headers,
1213
) {
13-
super(`Request error: ${body}`);
14+
super(`Request error: ${body}`, statusCode);
15+
// This is for backwards compatibility of pinejs-client-fetch users however
16+
// `statusCode` is what is expected by pinejs-client-core
17+
this.status = statusCode;
1418
}
1519
}
1620

0 commit comments

Comments
 (0)