Skip to content

Commit 530c134

Browse files
feat(api): manual updates (#33)
1 parent 1c7b4ad commit 530c134

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

aliases.go

+24
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@ import (
88
)
99

1010
type Error = apierror.Error
11+
type ErrorCode = apierror.ErrorCode
12+
13+
const ErrorCodeCanceled = apierror.ErrorCodeCanceled
14+
const ErrorCodeUnknown = apierror.ErrorCodeUnknown
15+
const ErrorCodeInvalidArgument = apierror.ErrorCodeInvalidArgument
16+
const ErrorCodeDeadlineExceeded = apierror.ErrorCodeDeadlineExceeded
17+
const ErrorCodeNotFound = apierror.ErrorCodeNotFound
18+
const ErrorCodeAlreadyExists = apierror.ErrorCodeAlreadyExists
19+
const ErrorCodePermissionDenied = apierror.ErrorCodePermissionDenied
20+
const ErrorCodeResourceExhausted = apierror.ErrorCodeResourceExhausted
21+
const ErrorCodeFailedPrecondition = apierror.ErrorCodeFailedPrecondition
22+
const ErrorCodeAborted = apierror.ErrorCodeAborted
23+
const ErrorCodeOutOfRange = apierror.ErrorCodeOutOfRange
24+
const ErrorCodeUnimplemented = apierror.ErrorCodeUnimplemented
25+
const ErrorCodeInternal = apierror.ErrorCodeInternal
26+
const ErrorCodeUnavailable = apierror.ErrorCodeUnavailable
27+
const ErrorCodeDataLoss = apierror.ErrorCodeDataLoss
28+
const ErrorCodeUnauthenticated = apierror.ErrorCodeUnauthenticated
29+
30+
type ArbitraryData = apierror.ArbitraryData
31+
type ArbitraryDataDebug = apierror.ArbitraryDataDebug
32+
type ArbitraryDataType = apierror.ArbitraryDataType
33+
type ArbitraryDataValue = apierror.ArbitraryDataValue
34+
type ArbitraryData = apierror.ArbitraryData
1135

1236
// An AutomationTrigger represents a trigger for an automation action. The
1337
// `post_environment_start` field indicates that the automation should be triggered

internal/apierror/apierror.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,36 @@ import (
88
"net/http/httputil"
99

1010
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
11+
"github.com/gitpod-io/gitpod-sdk-go/shared"
1112
)
1213

1314
// Error represents an error that originates from the API, i.e. when a request is
1415
// made and the API returns a response with a HTTP status code. Other errors are
1516
// not wrapped by this SDK.
1617
type Error struct {
17-
JSON errorJSON `json:"-"`
18-
StatusCode int
19-
Request *http.Request
20-
Response *http.Response
18+
// The status code, which should be an enum value of
19+
// [google.rpc.Code][google.rpc.Code].
20+
Code shared.ErrorCode `json:"code"`
21+
// Contains an arbitrary serialized message along with a @type that describes the
22+
// type of the serialized message.
23+
Detail shared.ArbitraryData `json:"detail"`
24+
// A developer-facing error message, which should be in English. Any user-facing
25+
// error message should be localized and sent in the
26+
// [google.rpc.Status.details][google.rpc.Status.details] field, or localized by
27+
// the client.
28+
Message string `json:"message"`
29+
ExtraFields map[string]interface{} `json:"-,extras"`
30+
JSON errorJSON `json:"-"`
31+
StatusCode int
32+
Request *http.Request
33+
Response *http.Response
2134
}
2235

2336
// errorJSON contains the JSON metadata for the struct [Error]
2437
type errorJSON struct {
38+
Code apijson.Field
39+
Detail apijson.Field
40+
Message apijson.Field
2541
raw string
2642
ExtraFields map[string]apijson.Field
2743
}

0 commit comments

Comments
 (0)