Skip to content

Commit 0386937

Browse files
authored
Merge pull request #316 from openai/release-please--branches--master--changes--next--components--openai
2 parents f52b3f5 + d3a30de commit 0386937

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.7.1"
2+
".": "4.8.0"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 4.8.0 (2023-09-15)
4+
5+
Full Changelog: [v4.7.1...v4.8.0](https://github.com/openai/openai-node/compare/v4.7.1...v4.8.0)
6+
7+
### Features
8+
9+
* **errors:** add status code to error message ([#315](https://github.com/openai/openai-node/issues/315)) ([9341219](https://github.com/openai/openai-node/commit/93412197c67cb3fb203f35e3ae0a7c3fb173453e))
10+
311
## 4.7.1 (2023-09-15)
412

513
Full Changelog: [v4.7.0...v4.7.1](https://github.com/openai/openai-node/compare/v4.7.0...v4.7.1)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openai",
3-
"version": "4.7.1",
3+
"version": "4.8.0",
44
"description": "Client library for the OpenAI API",
55
"author": "OpenAI <[email protected]>",
66
"types": "dist/index.d.ts",

src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ export abstract class APIClient {
377377
return this.retryRequest(options, retriesRemaining, responseHeaders);
378378
}
379379

380-
const errText = await response.text().catch(() => 'Unknown');
380+
const errText = await response.text().catch((e) => castToError(e).message);
381381
const errJSON = safeJSON(errText);
382382
const errMessage = errJSON ? undefined : errText;
383383

src/error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class APIError extends Error {
1717
message: string | undefined,
1818
headers: Headers | undefined,
1919
) {
20-
super(APIError.makeMessage(error, message));
20+
super(`${status} ${APIError.makeMessage(error, message)}`);
2121
this.status = status;
2222
this.headers = headers;
2323

@@ -34,7 +34,7 @@ export class APIError extends Error {
3434
typeof error.message === 'string' ? error.message
3535
: JSON.stringify(error.message)
3636
: error ? JSON.stringify(error)
37-
: message || 'Unknown error occurred'
37+
: message || 'status code (no body)'
3838
);
3939
}
4040

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = '4.7.1'; // x-release-please-version
1+
export const VERSION = '4.8.0'; // x-release-please-version

0 commit comments

Comments
 (0)