Remove error proto in favour of go type
This commit is contained in:
@@ -8,7 +8,12 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:generate protoc -I. --go_out=paths=source_relative:. errors.proto
|
||||
type Error struct {
|
||||
Id string
|
||||
Code int32
|
||||
Detail string
|
||||
Status string
|
||||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
b, _ := json.Marshal(e)
|
||||
@@ -119,40 +124,40 @@ func InternalServerError(id, format string, a ...interface{}) error {
|
||||
// NotImplemented generates a 501 error
|
||||
func NotImplemented(id, format string, a ...interface{}) error {
|
||||
return &Error{
|
||||
Id: id,
|
||||
Code: 501,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(501),
|
||||
Id: id,
|
||||
Code: 501,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(501),
|
||||
}
|
||||
}
|
||||
|
||||
// BadGateway generates a 502 error
|
||||
func BadGateway(id, format string, a ...interface{}) error {
|
||||
return &Error{
|
||||
Id: id,
|
||||
Code: 502,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(502),
|
||||
Id: id,
|
||||
Code: 502,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(502),
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceUnavailable generates a 503 error
|
||||
func ServiceUnavailable(id, format string, a ...interface{}) error {
|
||||
return &Error{
|
||||
Id: id,
|
||||
Code: 503,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(503),
|
||||
Id: id,
|
||||
Code: 503,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(503),
|
||||
}
|
||||
}
|
||||
|
||||
// GatewayTimeout generates a 504 error
|
||||
func GatewayTimeout(id, format string, a ...interface{}) error {
|
||||
return &Error{
|
||||
Id: id,
|
||||
Code: 504,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(504),
|
||||
Id: id,
|
||||
Code: 504,
|
||||
Detail: fmt.Sprintf(format, a...),
|
||||
Status: http.StatusText(504),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user