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