-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
39 lines (29 loc) · 1.05 KB
/
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
38
39
package pkg
import (
"github.com/gofiber/fiber/v2"
)
var (
ErrJWTDecodeAndVerify = NewError(fiber.StatusUnauthorized, "jwt.decode_and_verify", "failed to decode and verify jwt token")
ErrServerInternal = NewError(fiber.StatusInternalServerError, "server.internal_error", "internal server error")
ErrRecordNotFound = NewError(fiber.StatusNotFound, "record.not_found", "record not found")
ErrServerInvalidQuery = NewError(fiber.StatusBadRequest, "server.method.invalid_message_query", "invalid query")
ErrServerInvalidBody = NewError(fiber.StatusBadRequest, "server.method.invalid_message_body", "invalid body")
ErrTOTPCodeInvalid = NewError(fiber.StatusBadRequest, "totp.code.invalid", "totp code invalid")
)
type Error struct {
Errors []string `json:"errors"`
Code int `json:"-"`
Description string `json:"-"`
}
func NewError(code int, msg string, description string) *Error {
return &Error{
Errors: []string{
msg,
},
Code: code,
Description: description,
}
}
func (e *Error) Error() string {
return e.Description
}