Skip to content

Commit e7fbbe4

Browse files
committed
feat(shared): add standard error codes for API errors
1 parent ff2a3e5 commit e7fbbe4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

internal/apierror/error.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package apierror
2+
3+
import "github.com/gitpod-io/gitpod-sdk-go/shared"
4+
5+
type ErrorCode = shared.ErrorCode
6+
7+
const ErrorCodeCanceled = shared.ErrorCodeCanceled
8+
const ErrorCodeUnknown = shared.ErrorCodeUnknown
9+
const ErrorCodeInvalidArgument = shared.ErrorCodeInvalidArgument
10+
const ErrorCodeDeadlineExceeded = shared.ErrorCodeDeadlineExceeded
11+
const ErrorCodeNotFound = shared.ErrorCodeNotFound
12+
const ErrorCodeAlreadyExists = shared.ErrorCodeAlreadyExists
13+
const ErrorCodePermissionDenied = shared.ErrorCodePermissionDenied
14+
const ErrorCodeResourceExhausted = shared.ErrorCodeResourceExhausted
15+
const ErrorCodeFailedPrecondition = shared.ErrorCodeFailedPrecondition
16+
const ErrorCodeAborted = shared.ErrorCodeAborted
17+
const ErrorCodeOutOfRange = shared.ErrorCodeOutOfRange
18+
const ErrorCodeUnimplemented = shared.ErrorCodeUnimplemented
19+
const ErrorCodeInternal = shared.ErrorCodeInternal
20+
const ErrorCodeUnavailable = shared.ErrorCodeUnavailable
21+
const ErrorCodeDataLoss = shared.ErrorCodeDataLoss
22+
const ErrorCodeUnauthenticated = shared.ErrorCodeUnauthenticated

shared/error.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package shared
2+
3+
type ErrorCode string
4+
5+
const (
6+
ErrorCodeCanceled ErrorCode = "canceled"
7+
ErrorCodeUnknown ErrorCode = "unknown"
8+
ErrorCodeInvalidArgument ErrorCode = "invalid_argument"
9+
ErrorCodeDeadlineExceeded ErrorCode = "deadline_exceeded"
10+
ErrorCodeNotFound ErrorCode = "not_found"
11+
ErrorCodeAlreadyExists ErrorCode = "already_exists"
12+
ErrorCodePermissionDenied ErrorCode = "permission_denied"
13+
ErrorCodeResourceExhausted ErrorCode = "resource_exhausted"
14+
ErrorCodeFailedPrecondition ErrorCode = "failed_precondition"
15+
ErrorCodeAborted ErrorCode = "aborted"
16+
ErrorCodeOutOfRange ErrorCode = "out_of_range"
17+
ErrorCodeUnimplemented ErrorCode = "unimplemented"
18+
ErrorCodeInternal ErrorCode = "internal"
19+
ErrorCodeUnavailable ErrorCode = "unavailable"
20+
ErrorCodeDataLoss ErrorCode = "data_loss"
21+
ErrorCodeUnauthenticated ErrorCode = "unauthenticated"
22+
)
23+
24+
type ArbitraryData = any

0 commit comments

Comments
 (0)