Skip to content

Commit

Permalink
Merge pull request #316 from openai/release-please--branches--master-…
Browse files Browse the repository at this point in the history
…-changes--next--components--openai
  • Loading branch information
athyuttamre authored Sep 18, 2023
2 parents f52b3f5 + d3a30de commit 0386937
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.7.1"
".": "4.8.0"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.8.0 (2023-09-15)

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

### Features

* **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))

## 4.7.1 (2023-09-15)

Full Changelog: [v4.7.0...v4.7.1](https://github.com/openai/openai-node/compare/v4.7.0...v4.7.1)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "4.7.1",
"version": "4.8.0",
"description": "Client library for the OpenAI API",
"author": "OpenAI <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export abstract class APIClient {
return this.retryRequest(options, retriesRemaining, responseHeaders);
}

const errText = await response.text().catch(() => 'Unknown');
const errText = await response.text().catch((e) => castToError(e).message);
const errJSON = safeJSON(errText);
const errMessage = errJSON ? undefined : errText;

Expand Down
4 changes: 2 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class APIError extends Error {
message: string | undefined,
headers: Headers | undefined,
) {
super(APIError.makeMessage(error, message));
super(`${status} ${APIError.makeMessage(error, message)}`);
this.status = status;
this.headers = headers;

Expand All @@ -34,7 +34,7 @@ export class APIError extends Error {
typeof error.message === 'string' ? error.message
: JSON.stringify(error.message)
: error ? JSON.stringify(error)
: message || 'Unknown error occurred'
: message || 'status code (no body)'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '4.7.1'; // x-release-please-version
export const VERSION = '4.8.0'; // x-release-please-version

0 comments on commit 0386937

Please sign in to comment.