-
Notifications
You must be signed in to change notification settings - Fork 3
/
err.go
54 lines (47 loc) · 1.23 KB
/
err.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package trash
import (
"io"
"net/http"
)
const (
AlreadyExistErr = "ALREADY EXIST"
AuthErr = "AUTHENTIFICATION ERROR"
BadRequestErr = "BAD REQUEST"
DbErr = "DATABASE ERROR"
DeserializationErr = "DESERIALIZATION ERROR"
FileErr = "FILE ERROR"
GenericErr = "GENERIC ERROR"
InvalidJSONErr = "INVALID JSON"
InvalidXMLErr = "INVALID XML ERROR"
InvalidDataErr = "INVALID DATA "
InternalErr = "INTERNAL SERVER ERROR"
NotFoundErr = "NOT FOUND"
UnauthorizedAccessErr = "UNAUTHORIZED ACCESS ERROR"
)
type genErr interface {
Err
HTTPErr
FmtErr
}
// Err is the default interface for trash
type Err interface {
Send(io.Writer) Err
Log() Err
Error() string
}
// HTTPErr is a upgrade from Err adding HTTP Send and Log
type HTTPErr interface {
SendHTTP(http.ResponseWriter, int) HTTPErr
LogHTTP(*http.Request) HTTPErr
}
// FmtErr is the Err formatting interface{}
type FmtErr interface {
FormatErr() string
}
// Error is the default error type
type errData struct {
ID string `json:"id" xml:"id"`
Type string `json:"type" xml:"type"`
Message string `json:"message" xml:"message"`
Code int `json:"code" xml:"code"`
}