Skip to content

Commit c395264

Browse files
committed
修正重复添加状态码的bug
1 parent 8cd747b commit c395264

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default class Api2d
5858
const timeout_handle = setTimeout( () => {
5959
this.controller.abort();
6060
// throw new Error( "Timeout "+ this.timeout );
61-
reject( new Error( `[408]:Timeout by ${this.timeout} ms` ) ); z
61+
reject( new Error( `[408]:Timeout by ${this.timeout} ms` ) );
6262
}, this.timeout );
6363
const response = await fetchEventSource( url, {
6464
signal: this.controller.signal,
@@ -93,7 +93,7 @@ export default class Api2d
9393
},
9494
onerror: error => {
9595
console.log( error );
96-
throw new Error( `[500]:${error}` );
96+
throw new Error( String(error)?.match(/\[(\d+)\]/)?.[1] ? error : `[500]:${error}` );
9797
}
9898
});
9999

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api2d",
3-
"version": "0.1.9",
3+
"version": "0.1.11",
44
"description": "pure browser sdk for api2d and openai",
55
"main": "index.js",
66
"repository": "https://github.com/easychen/api2d-js",

0 commit comments

Comments
 (0)