-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy patherror_mapping.go
executable file
·58 lines (53 loc) · 3.22 KB
/
error_mapping.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package apierr
import (
"errors"
)
var (
ErrBadRequest = errors.New("the request is invalid")
ErrUnauthenticated = errors.New("the request does not have valid authentication (AuthN) credentials for the operation")
ErrPermissionDenied = errors.New("the caller does not have permission to execute the specified operation")
ErrNotFound = errors.New("the operation was performed on a resource that does not exist")
ErrResourceConflict = errors.New("maps to all HTTP 409 (Conflict) responses")
ErrTooManyRequests = errors.New("maps to HTTP code: 429 Too Many Requests")
ErrCancelled = errors.New("the operation was explicitly canceled by the caller")
ErrInternalError = errors.New("some invariants expected by the underlying system have been broken")
ErrNotImplemented = errors.New("the operation is not implemented or is not supported/enabled in this service")
ErrTemporarilyUnavailable = errors.New("the service is currently unavailable")
ErrDeadlineExceeded = errors.New("the deadline expired before the operation could complete")
ErrInvalidParameterValue = inheritErr(ErrBadRequest, "supplied value for a parameter was invalid")
ErrFeatureDisabled = inheritErr(ErrNotFound, "feature is disabled for the current workspace")
ErrResourceDoesNotExist = inheritErr(ErrNotFound, "operation was performed on a resource that does not exist")
ErrAborted = inheritErr(ErrResourceConflict, "the operation was aborted, typically due to a concurrency issue such as a sequencer check failure")
ErrAlreadyExists = inheritErr(ErrResourceConflict, "operation was rejected due a conflict with an existing resource")
ErrResourceAlreadyExists = inheritErr(ErrResourceConflict, "operation was rejected due a conflict with an existing resource")
ErrResourceExhausted = inheritErr(ErrTooManyRequests, "operation is rejected due to per-user rate limiting")
ErrRequestLimitExceeded = inheritErr(ErrTooManyRequests, "cluster request was rejected because it would exceed a resource limit")
ErrUnknown = inheritErr(ErrInternalError, "this error is used as a fallback if the platform-side mapping is missing some reason")
ErrDataLoss = inheritErr(ErrInternalError, "unrecoverable data loss or corruption")
statusCodeMapping = map[int]error{
400: ErrBadRequest,
401: ErrUnauthenticated,
403: ErrPermissionDenied,
404: ErrNotFound,
409: ErrResourceConflict,
429: ErrTooManyRequests,
499: ErrCancelled,
500: ErrInternalError,
501: ErrNotImplemented,
503: ErrTemporarilyUnavailable,
504: ErrDeadlineExceeded,
}
errorCodeMapping = map[string]error{
"INVALID_PARAMETER_VALUE": ErrInvalidParameterValue,
"FEATURE_DISABLED": ErrFeatureDisabled,
"RESOURCE_DOES_NOT_EXIST": ErrResourceDoesNotExist,
"ABORTED": ErrAborted,
"ALREADY_EXISTS": ErrAlreadyExists,
"RESOURCE_ALREADY_EXISTS": ErrResourceAlreadyExists,
"RESOURCE_EXHAUSTED": ErrResourceExhausted,
"REQUEST_LIMIT_EXCEEDED": ErrRequestLimitExceeded,
"UNKNOWN": ErrUnknown,
"DATA_LOSS": ErrDataLoss,
}
)