blob: 1104c4fa6c123571d7141a27d9c8163d0c9fc45e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package errors
import (
"encoding/json"
)
type AppError struct {
Status int `json:"code"`
Message json.RawMessage `json:"message"`
}
func NewAppError(status int, msg string) *AppError {
msgJSON, err := json.Marshal(map[string]string{"message": msg})
if err != nil {
msgJSON, _ = json.Marshal(map[string]string{"message": err.Error()})
}
return &AppError{status, msgJSON}
}
|