Skip to content

Commit 398339d

Browse files
authored
feat(apiresponses): Add ErrInstanceNotFound error (#364)
Adding a instance not found error (statusCode=404). This allows users of this library to reply with a predefined error when fetching a instance didn't find any instances.
1 parent c5502f9 commit 398339d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

domain/apiresponses/errors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
const (
99
instanceExistsMsg = "instance already exists"
1010
instanceDoesntExistMsg = "instance does not exist"
11+
instanceNotFoundMsg = "instance cannot be fetched"
1112
serviceLimitReachedMsg = "instance limit for this service has been reached"
1213
servicePlanQuotaExceededMsg = "The quota for this service plan has been exceeded. Please contact your Operator for help."
1314
serviceQuotaExceededMsg = "The quota for this service has been exceeded. Please contact your Operator for help."
@@ -26,6 +27,7 @@ const (
2627
instanceAlreadyExistsErrorKey = "instance-already-exists"
2728
bindingAlreadyExistsErrorKey = "binding-already-exists"
2829
instanceMissingErrorKey = "instance-missing"
30+
instanceNotFoundErrorKey = "instance-not-found"
2931
bindingMissingErrorKey = "binding-missing"
3032
bindingNotFoundErrorKey = "binding-not-found"
3133
asyncRequiredKey = "async-required"
@@ -45,6 +47,10 @@ var (
4547
errors.New(instanceDoesntExistMsg), http.StatusGone, instanceMissingErrorKey,
4648
).WithEmptyResponse().Build()
4749

50+
ErrInstanceNotFound = NewFailureResponseBuilder(
51+
errors.New(instanceDoesntExistMsg), http.StatusNotFound, instanceNotFoundErrorKey,
52+
).WithEmptyResponse().Build()
53+
4854
ErrInstanceLimitMet = NewFailureResponse(
4955
errors.New(serviceLimitReachedMsg), http.StatusInternalServerError, instanceLimitReachedErrorKey,
5056
)

service_broker.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ var (
113113

114114
ErrInstanceDoesNotExist = apiresponses.ErrInstanceDoesNotExist
115115

116+
ErrInstanceNotFound = apiresponses.ErrInstanceNotFound
117+
116118
ErrInstanceLimitMet = apiresponses.ErrInstanceLimitMet
117119

118120
ErrBindingAlreadyExists = apiresponses.ErrBindingAlreadyExists

0 commit comments

Comments
 (0)