-
Notifications
You must be signed in to change notification settings - Fork 70
/
errors.go
94 lines (77 loc) · 4.3 KB
/
errors.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package apiresponses
import (
"errors"
"net/http"
)
const (
instanceExistsMsg = "instance already exists"
instanceDoesntExistMsg = "instance does not exist"
serviceLimitReachedMsg = "instance limit for this service has been reached"
servicePlanQuotaExceededMsg = "The quota for this service plan has been exceeded. Please contact your Operator for help."
serviceQuotaExceededMsg = "The quota for this service has been exceeded. Please contact your Operator for help."
bindingExistsMsg = "binding already exists"
bindingDoesntExistMsg = "binding does not exist"
bindingNotFoundMsg = "binding cannot be fetched"
asyncRequiredMsg = "This service plan requires client support for asynchronous service operations."
planChangeUnsupportedMsg = "The requested plan migration cannot be performed"
rawInvalidParamsMsg = "The format of the parameters is not valid JSON"
appGuidMissingMsg = "app_guid is a required field but was not provided"
concurrentInstanceAccessMsg = "instance is being updated and cannot be retrieved"
maintenanceInfoConflictMsg = "passed maintenance_info does not match the catalog maintenance_info"
maintenanceInfoNilConflictMsg = "maintenance_info was passed, but the broker catalog contains no maintenance_info"
instanceLimitReachedErrorKey = "instance-limit-reached"
instanceAlreadyExistsErrorKey = "instance-already-exists"
bindingAlreadyExistsErrorKey = "binding-already-exists"
instanceMissingErrorKey = "instance-missing"
bindingMissingErrorKey = "binding-missing"
bindingNotFoundErrorKey = "binding-not-found"
asyncRequiredKey = "async-required"
planChangeNotSupportedKey = "plan-change-not-supported"
invalidRawParamsKey = "invalid-raw-params"
appGuidNotProvidedErrorKey = "app-guid-not-provided"
concurrentAccessKey = "get-instance-during-update"
maintenanceInfoConflictKey = "maintenance-info-conflict"
)
var (
ErrInstanceAlreadyExists = NewFailureResponseBuilder(
errors.New(instanceExistsMsg), http.StatusConflict, instanceAlreadyExistsErrorKey,
).WithEmptyResponse().Build()
ErrInstanceDoesNotExist = NewFailureResponseBuilder(
errors.New(instanceDoesntExistMsg), http.StatusGone, instanceMissingErrorKey,
).WithEmptyResponse().Build()
ErrInstanceLimitMet = NewFailureResponse(
errors.New(serviceLimitReachedMsg), http.StatusInternalServerError, instanceLimitReachedErrorKey,
)
ErrBindingAlreadyExists = NewFailureResponse(
errors.New(bindingExistsMsg), http.StatusConflict, bindingAlreadyExistsErrorKey,
)
ErrBindingDoesNotExist = NewFailureResponseBuilder(
errors.New(bindingDoesntExistMsg), http.StatusGone, bindingMissingErrorKey,
).WithEmptyResponse().Build()
ErrBindingNotFound = NewFailureResponseBuilder(
errors.New(bindingNotFoundMsg), http.StatusNotFound, bindingNotFoundErrorKey,
).WithEmptyResponse().Build()
ErrAsyncRequired = NewFailureResponseBuilder(
errors.New(asyncRequiredMsg), http.StatusUnprocessableEntity, asyncRequiredKey,
).WithErrorKey("AsyncRequired").Build()
ErrPlanChangeNotSupported = NewFailureResponseBuilder(
errors.New(planChangeUnsupportedMsg), http.StatusUnprocessableEntity, planChangeNotSupportedKey,
).WithErrorKey("PlanChangeNotSupported").Build()
ErrRawParamsInvalid = NewFailureResponse(
errors.New(rawInvalidParamsMsg), http.StatusUnprocessableEntity, invalidRawParamsKey,
)
ErrAppGuidNotProvided = NewFailureResponse(
errors.New(appGuidMissingMsg), http.StatusUnprocessableEntity, appGuidNotProvidedErrorKey,
)
ErrPlanQuotaExceeded = errors.New(servicePlanQuotaExceededMsg)
ErrServiceQuotaExceeded = errors.New(serviceQuotaExceededMsg)
ErrConcurrentInstanceAccess = NewFailureResponseBuilder(
errors.New(concurrentInstanceAccessMsg), http.StatusUnprocessableEntity, concurrentAccessKey,
).WithErrorKey("ConcurrencyError").Build()
ErrMaintenanceInfoConflict = NewFailureResponseBuilder(
errors.New(maintenanceInfoConflictMsg), http.StatusUnprocessableEntity, maintenanceInfoConflictKey,
).WithErrorKey("MaintenanceInfoConflict").Build()
ErrMaintenanceInfoNilConflict = NewFailureResponseBuilder(
errors.New(maintenanceInfoNilConflictMsg), http.StatusUnprocessableEntity, maintenanceInfoConflictKey,
).WithErrorKey("MaintenanceInfoConflict").Build()
)