Skip to content

Commit

Permalink
fix: structure error returned without nested errors (#2629)
Browse files Browse the repository at this point in the history
* structure error returned

* remove log

* Update packages/api/src/client.ts

simplify

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* [autofix.ci] apply automated fixes

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent b25fd9f commit c09c526
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/api/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ type Result<R> =
}
| {
result?: never;
error: ErrorResponse["error"];
error: {
code: ErrorResponse["error"]["code"];
message: ErrorResponse["error"]["message"];
docs: ErrorResponse["error"]["docs"];
requestId: string;
};
};

export class Unkey {
Expand Down Expand Up @@ -190,9 +195,11 @@ export class Unkey {
}

if (res) {
return { error: (await res.json()) as ErrorResponse["error"] };
const { code, message, docs, requestId } = (await res.json()) as ErrorResponse["error"];
return {
error: { code, message, docs, requestId },
};
}

return {
error: {
// @ts-ignore
Expand Down

0 comments on commit c09c526

Please sign in to comment.