2929 // ErrBadRequest is returned is a malformed request is sent
3030 ErrBadRequest = NewBadRequestError ("invalid request" )
3131 // ErrTimeout is returned when a timeout occurs.
32- ErrTimeout = fmt . Errorf ("timed out" )
33- ErrUnprocessable = fmt . Errorf ("cannot process request" )
34- ErrNoPoolsAvailable = fmt . Errorf ("no pools available" )
32+ ErrTimeout = NewTimeoutError ("timed out" )
33+ ErrUnprocessable = NewUnprocessableError ("cannot process request" )
34+ ErrNoPoolsAvailable = NewNoPoolsAvailableError ("no pools available" )
3535)
3636
3737type baseError struct {
@@ -56,6 +56,15 @@ type ProviderError struct {
5656 baseError
5757}
5858
59+ func (p * ProviderError ) Is (target error ) bool {
60+ if target == nil {
61+ return false
62+ }
63+
64+ _ , ok := target .(* ProviderError )
65+ return ok
66+ }
67+
5968// NewMissingSecretError returns a new MissingSecretError
6069func NewMissingSecretError (msg string , a ... interface {}) error {
6170 return & MissingSecretError {
@@ -70,6 +79,15 @@ type MissingSecretError struct {
7079 baseError
7180}
7281
82+ func (p * MissingSecretError ) Is (target error ) bool {
83+ if target == nil {
84+ return false
85+ }
86+
87+ _ , ok := target .(* MissingSecretError )
88+ return ok
89+ }
90+
7391// NewUnauthorizedError returns a new UnauthorizedError
7492func NewUnauthorizedError (msg string ) error {
7593 return & UnauthorizedError {
@@ -84,6 +102,15 @@ type UnauthorizedError struct {
84102 baseError
85103}
86104
105+ func (p * UnauthorizedError ) Is (target error ) bool {
106+ if target == nil {
107+ return false
108+ }
109+
110+ _ , ok := target .(* UnauthorizedError )
111+ return ok
112+ }
113+
87114// NewNotFoundError returns a new NotFoundError
88115func NewNotFoundError (msg string , a ... interface {}) error {
89116 return & NotFoundError {
@@ -98,6 +125,15 @@ type NotFoundError struct {
98125 baseError
99126}
100127
128+ func (p * NotFoundError ) Is (target error ) bool {
129+ if target == nil {
130+ return false
131+ }
132+
133+ _ , ok := target .(* NotFoundError )
134+ return ok
135+ }
136+
101137// NewDuplicateUserError returns a new DuplicateUserError
102138func NewDuplicateUserError (msg string ) error {
103139 return & DuplicateUserError {
@@ -112,6 +148,15 @@ type DuplicateUserError struct {
112148 baseError
113149}
114150
151+ func (p * DuplicateUserError ) Is (target error ) bool {
152+ if target == nil {
153+ return false
154+ }
155+
156+ _ , ok := target .(* DuplicateUserError )
157+ return ok
158+ }
159+
115160// NewBadRequestError returns a new BadRequestError
116161func NewBadRequestError (msg string , a ... interface {}) error {
117162 return & BadRequestError {
@@ -126,6 +171,15 @@ type BadRequestError struct {
126171 baseError
127172}
128173
174+ func (p * BadRequestError ) Is (target error ) bool {
175+ if target == nil {
176+ return false
177+ }
178+
179+ _ , ok := target .(* BadRequestError )
180+ return ok
181+ }
182+
129183// NewConflictError returns a new ConflictError
130184func NewConflictError (msg string , a ... interface {}) error {
131185 return & ConflictError {
@@ -139,3 +193,81 @@ func NewConflictError(msg string, a ...interface{}) error {
139193type ConflictError struct {
140194 baseError
141195}
196+
197+ func (p * ConflictError ) Is (target error ) bool {
198+ if target == nil {
199+ return false
200+ }
201+
202+ _ , ok := target .(* ConflictError )
203+ return ok
204+ }
205+
206+ // NewTimeoutError returns a new TimoutError
207+ func NewTimeoutError (msg string , a ... interface {}) error {
208+ return & TimoutError {
209+ baseError {
210+ msg : fmt .Sprintf (msg , a ... ),
211+ },
212+ }
213+ }
214+
215+ // TimoutError is returned when an operation times out.
216+ type TimoutError struct {
217+ baseError
218+ }
219+
220+ func (p * TimoutError ) Is (target error ) bool {
221+ if target == nil {
222+ return false
223+ }
224+
225+ _ , ok := target .(* TimoutError )
226+ return ok
227+ }
228+
229+ // NewUnprocessableError returns a new UnprocessableError
230+ func NewUnprocessableError (msg string , a ... interface {}) error {
231+ return & TimoutError {
232+ baseError {
233+ msg : fmt .Sprintf (msg , a ... ),
234+ },
235+ }
236+ }
237+
238+ // TimoutError is returned when an operation times out.
239+ type UnprocessableError struct {
240+ baseError
241+ }
242+
243+ func (p * UnprocessableError ) Is (target error ) bool {
244+ if target == nil {
245+ return false
246+ }
247+
248+ _ , ok := target .(* UnprocessableError )
249+ return ok
250+ }
251+
252+ // NewNoPoolsAvailableError returns a new UnprocessableError
253+ func NewNoPoolsAvailableError (msg string , a ... interface {}) error {
254+ return & TimoutError {
255+ baseError {
256+ msg : fmt .Sprintf (msg , a ... ),
257+ },
258+ }
259+ }
260+
261+ // NoPoolsAvailableError is returned when anthere are not pools available.
262+ type NoPoolsAvailableError struct {
263+ baseError
264+ }
265+
266+ func (p * NoPoolsAvailableError ) Is (target error ) bool {
267+ if target == nil {
268+ return false
269+ }
270+
271+ _ , ok := target .(* NoPoolsAvailableError )
272+ return ok
273+ }
0 commit comments