Skip to content

Commit e935d2b

Browse files
feat(api): manual updates (#20)
1 parent c6c8b20 commit e935d2b

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

api.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
Types:
44

5+
- <code><a href="./src/resources/shared.ts">ArbitraryData</a></code>
56
- <code><a href="./src/resources/shared.ts">AutomationTrigger</a></code>
67
- <code><a href="./src/resources/shared.ts">EnvironmentClass</a></code>
8+
- <code><a href="./src/resources/shared.ts">ErrorCode</a></code>
79
- <code><a href="./src/resources/shared.ts">FieldValue</a></code>
810
- <code><a href="./src/resources/shared.ts">OrganizationRole</a></code>
911
- <code><a href="./src/resources/shared.ts">Principal</a></code>

src/client.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,10 @@ export declare namespace Gitpod {
11451145
type UserSetSuspendedParams as UserSetSuspendedParams,
11461146
};
11471147

1148+
export type ArbitraryData = API.ArbitraryData;
11481149
export type AutomationTrigger = API.AutomationTrigger;
11491150
export type EnvironmentClass = API.EnvironmentClass;
1151+
export type ErrorCode = API.ErrorCode;
11501152
export type FieldValue = API.FieldValue;
11511153
export type OrganizationRole = API.OrganizationRole;
11521154
export type Principal = API.Principal;

src/error.ts

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { castToError } from './internal/errors';
4+
import * as Shared from './resources/shared';
45

56
export class GitpodError extends Error {}
67

@@ -16,11 +17,26 @@ export class APIError<
1617
/** JSON body of the response that caused the error */
1718
readonly error: TError;
1819

20+
/**
21+
* The status code, which should be an enum value of
22+
* [google.rpc.Code][google.rpc.Code].
23+
*/
24+
readonly code?: Shared.ErrorCode | undefined;
25+
/**
26+
* Contains an arbitrary serialized message along with a @type that describes the
27+
* type of the serialized message.
28+
*/
29+
readonly detail?: Shared.ArbitraryData | undefined;
30+
1931
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
2032
super(`${APIError.makeMessage(status, error, message)}`);
2133
this.status = status;
2234
this.headers = headers;
2335
this.error = error;
36+
37+
const data = error as Record<string, any>;
38+
this.code = data?.['code'];
39+
this.detail = data?.['detail'];
2440
}
2541

2642
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {

src/resources/shared.ts

+36
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
import * as Shared from './shared';
44
import { EnvironmentClassesPage, TaskExecutionsPage, TasksPage } from '../pagination';
5+
import { type Uploadable } from '../uploads';
6+
7+
/**
8+
* Contains an arbitrary serialized message along with a @type that describes the
9+
* type of the serialized message.
10+
*/
11+
export interface ArbitraryData {
12+
debug?: Record<string, unknown>;
13+
14+
type?: string;
15+
16+
value?: Uploadable;
17+
[k: string]: unknown;
18+
}
519

620
/**
721
* An AutomationTrigger represents a trigger for an automation action. The
@@ -51,6 +65,28 @@ export interface EnvironmentClass {
5165
runnerId?: string;
5266
}
5367

68+
/**
69+
* The status code, which should be an enum value of
70+
* [google.rpc.Code][google.rpc.Code].
71+
*/
72+
export type ErrorCode =
73+
| 'canceled'
74+
| 'unknown'
75+
| 'invalid_argument'
76+
| 'deadline_exceeded'
77+
| 'not_found'
78+
| 'already_exists'
79+
| 'permission_denied'
80+
| 'resource_exhausted'
81+
| 'failed_precondition'
82+
| 'aborted'
83+
| 'out_of_range'
84+
| 'unimplemented'
85+
| 'internal'
86+
| 'unavailable'
87+
| 'data_loss'
88+
| 'unauthenticated';
89+
5490
export interface FieldValue {
5591
key?: string;
5692

0 commit comments

Comments
 (0)