-
Notifications
You must be signed in to change notification settings - Fork 53
/
errors.go
37 lines (30 loc) · 917 Bytes
/
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
package fargo
// MIT Licensed (see README.md) - Copyright (c) 2013 Hudl <@Hudl>
import (
"fmt"
)
type unsuccessfulHTTPResponse struct {
statusCode int
messagePrefix string
}
func (u *unsuccessfulHTTPResponse) Error() string {
if len(u.messagePrefix) > 0 {
return fmt.Sprint(u.messagePrefix, ", rcode = ", u.statusCode)
}
return fmt.Sprint("rcode = ", u.statusCode)
}
// HTTPResponseStatusCode extracts the HTTP status code for the response from Eureka that motivated
// the supplied error, if any. If the returned present value is true, the returned code is an HTTP
// status code.
func HTTPResponseStatusCode(err error) (code int, present bool) {
if u, ok := err.(*unsuccessfulHTTPResponse); ok {
return u.statusCode, true
}
return 0, false
}
type AppNotFoundError struct {
specific string
}
func (e AppNotFoundError) Error() string {
return "Application not found for name=" + e.specific
}