Skip to content

Commit

Permalink
feat(shared): add standard error codes for API errors (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov authored Feb 18, 2025
1 parent ff2a3e5 commit 716a125
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ module github.com/gitpod-io/gitpod-sdk-go
go 1.21

require (
github.com/google/uuid v1.3.0 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/gjson v1.14.4
github.com/tidwall/sjson v1.2.5
)

require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
Expand Down
22 changes: 22 additions & 0 deletions internal/apierror/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package apierror

import "github.com/gitpod-io/gitpod-sdk-go/shared"

type ErrorCode = shared.ErrorCode

const ErrorCodeCanceled = shared.ErrorCodeCanceled
const ErrorCodeUnknown = shared.ErrorCodeUnknown
const ErrorCodeInvalidArgument = shared.ErrorCodeInvalidArgument
const ErrorCodeDeadlineExceeded = shared.ErrorCodeDeadlineExceeded
const ErrorCodeNotFound = shared.ErrorCodeNotFound
const ErrorCodeAlreadyExists = shared.ErrorCodeAlreadyExists
const ErrorCodePermissionDenied = shared.ErrorCodePermissionDenied
const ErrorCodeResourceExhausted = shared.ErrorCodeResourceExhausted
const ErrorCodeFailedPrecondition = shared.ErrorCodeFailedPrecondition
const ErrorCodeAborted = shared.ErrorCodeAborted
const ErrorCodeOutOfRange = shared.ErrorCodeOutOfRange
const ErrorCodeUnimplemented = shared.ErrorCodeUnimplemented
const ErrorCodeInternal = shared.ErrorCodeInternal
const ErrorCodeUnavailable = shared.ErrorCodeUnavailable
const ErrorCodeDataLoss = shared.ErrorCodeDataLoss
const ErrorCodeUnauthenticated = shared.ErrorCodeUnauthenticated
22 changes: 22 additions & 0 deletions shared/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package shared

type ErrorCode string

const (
ErrorCodeCanceled ErrorCode = "canceled"
ErrorCodeUnknown ErrorCode = "unknown"
ErrorCodeInvalidArgument ErrorCode = "invalid_argument"
ErrorCodeDeadlineExceeded ErrorCode = "deadline_exceeded"
ErrorCodeNotFound ErrorCode = "not_found"
ErrorCodeAlreadyExists ErrorCode = "already_exists"
ErrorCodePermissionDenied ErrorCode = "permission_denied"
ErrorCodeResourceExhausted ErrorCode = "resource_exhausted"
ErrorCodeFailedPrecondition ErrorCode = "failed_precondition"
ErrorCodeAborted ErrorCode = "aborted"
ErrorCodeOutOfRange ErrorCode = "out_of_range"
ErrorCodeUnimplemented ErrorCode = "unimplemented"
ErrorCodeInternal ErrorCode = "internal"
ErrorCodeUnavailable ErrorCode = "unavailable"
ErrorCodeDataLoss ErrorCode = "data_loss"
ErrorCodeUnauthenticated ErrorCode = "unauthenticated"
)

0 comments on commit 716a125

Please # to comment.