blob: 2b90d210efe42c40f5c4fbcdc1fb7d3790f1d86d (
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}
}
|