diff --git a/api.md b/api.md
index 9eb234c..ac4a55a 100644
--- a/api.md
+++ b/api.md
@@ -2,8 +2,10 @@
Types:
+- ArbitraryData
- AutomationTrigger
- EnvironmentClass
+- ErrorCode
- FieldValue
- OrganizationRole
- Principal
diff --git a/src/client.ts b/src/client.ts
index b166c8a..c118587 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -1145,8 +1145,10 @@ export declare namespace Gitpod {
type UserSetSuspendedParams as UserSetSuspendedParams,
};
+ export type ArbitraryData = API.ArbitraryData;
export type AutomationTrigger = API.AutomationTrigger;
export type EnvironmentClass = API.EnvironmentClass;
+ export type ErrorCode = API.ErrorCode;
export type FieldValue = API.FieldValue;
export type OrganizationRole = API.OrganizationRole;
export type Principal = API.Principal;
diff --git a/src/error.ts b/src/error.ts
index 0e55642..1169f9b 100644
--- a/src/error.ts
+++ b/src/error.ts
@@ -1,6 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { castToError } from './internal/errors';
+import * as Shared from './resources/shared';
export class GitpodError extends Error {}
@@ -16,11 +17,26 @@ export class APIError<
/** JSON body of the response that caused the error */
readonly error: TError;
+ /**
+ * The status code, which should be an enum value of
+ * [google.rpc.Code][google.rpc.Code].
+ */
+ readonly code?: Shared.ErrorCode | undefined;
+ /**
+ * Contains an arbitrary serialized message along with a @type that describes the
+ * type of the serialized message.
+ */
+ readonly detail?: Shared.ArbitraryData | undefined;
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
this.error = error;
+
+ const data = error as Record;
+ this.code = data?.['code'];
+ this.detail = data?.['detail'];
}
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
diff --git a/src/resources/shared.ts b/src/resources/shared.ts
index 8edf98a..0ef958f 100644
--- a/src/resources/shared.ts
+++ b/src/resources/shared.ts
@@ -2,6 +2,20 @@
import * as Shared from './shared';
import { EnvironmentClassesPage, TaskExecutionsPage, TasksPage } from '../pagination';
+import { type Uploadable } from '../uploads';
+
+/**
+ * Contains an arbitrary serialized message along with a @type that describes the
+ * type of the serialized message.
+ */
+export interface ArbitraryData {
+ debug?: Record;
+
+ type?: string;
+
+ value?: Uploadable;
+ [k: string]: unknown;
+}
/**
* An AutomationTrigger represents a trigger for an automation action. The
@@ -51,6 +65,28 @@ export interface EnvironmentClass {
runnerId?: string;
}
+/**
+ * The status code, which should be an enum value of
+ * [google.rpc.Code][google.rpc.Code].
+ */
+export type ErrorCode =
+ | 'canceled'
+ | 'unknown'
+ | 'invalid_argument'
+ | 'deadline_exceeded'
+ | 'not_found'
+ | 'already_exists'
+ | 'permission_denied'
+ | 'resource_exhausted'
+ | 'failed_precondition'
+ | 'aborted'
+ | 'out_of_range'
+ | 'unimplemented'
+ | 'internal'
+ | 'unavailable'
+ | 'data_loss'
+ | 'unauthenticated';
+
export interface FieldValue {
key?: string;