Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Mar 21, 2024
1 parent 84eba2c commit 3ba723d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Shared

Types:

- <code><a href="./src/resources/shared.ts">ErrorData</a></code>

# Accounts

Types:
Expand Down
8 changes: 7 additions & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { castToError, Headers } from './core';
import * as Shared from 'cloudflare/resources/shared';

export class CloudflareError extends Error {}

Expand All @@ -9,6 +10,8 @@ export class APIError extends CloudflareError {
readonly headers: Headers | undefined;
readonly error: Object | undefined;

readonly errors: Array<Shared.ErrorData>;

constructor(
status: number | undefined,
error: Object | undefined,
Expand All @@ -18,7 +21,10 @@ export class APIError extends CloudflareError {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
this.error = error;

const data = error as Record<string, any>;
this.error = data;
this.errors = data?.['errors'] ?? [];
}

private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ export namespace Cloudflare {
export import CallGetParams = API.CallGetParams;

export import CloudforceOne = API.CloudforceOne;

export import ErrorData = API.ErrorData;
}

export default Cloudflare;
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './shared';
export { ACM } from './acm/acm';
export {
Account,
Expand Down
7 changes: 7 additions & 0 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export interface ErrorData {
code?: number;

message?: string;
}

0 comments on commit 3ba723d

Please sign in to comment.