-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy patherror.go
38 lines (31 loc) · 832 Bytes
/
error.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
/*
2019 © Postgres.ai
*/
// Package models provides Database Lab struct.
package models
// ErrorCode defines a response error type.
type ErrorCode string
// ErrCode constants define a response error codes.
const (
ErrCodeInternal ErrorCode = "INTERNAL_ERROR"
ErrCodeBadRequest ErrorCode = "BAD_REQUEST"
ErrCodeUnauthorized ErrorCode = "UNAUTHORIZED"
ErrCodeNotFound ErrorCode = "NOT_FOUND"
)
// Error struct represents a response error.
type Error struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
}
var _ error = &Error{}
// New creates ClientError instance with given code and message.
func New(code ErrorCode, message string) *Error {
return &Error{
Code: code,
Message: message,
}
}
// Error prints an error message.
func (e Error) Error() string {
return e.Message
}