mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
Fixes #5: added status 500 to each error reply + pumped version number
This commit is contained in:
parent
37d649fbef
commit
a54924ee8d
@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
uniqushPushVersion = "content-server 1.3.0"
|
||||
uniqushPushVersion = "content-server 1.3.1"
|
||||
showVersionFlag = flag.Bool("version", false, "version info")
|
||||
address = flag.String("address", "127.0.0.1:8081", "address to bind host:port")
|
||||
varDir = flag.String("var-dir", "/var/lib/contentserver", "where to put my data")
|
||||
@ -66,7 +66,6 @@ func main() {
|
||||
level = log.LevelNotice
|
||||
case logLevelDebug:
|
||||
level = log.LevelDebug
|
||||
|
||||
}
|
||||
log.SelectedLevel = level
|
||||
err := server.Run(flag.Arg(0), *address, *varDir)
|
||||
|
||||
@ -4,17 +4,19 @@ import "fmt"
|
||||
|
||||
// Error describes an error for humans and machines
|
||||
type Error struct {
|
||||
Status int `json:"status"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (e Error) Error() string {
|
||||
return fmt.Sprintf("code: %q, message: %q", e.Code, e.Message)
|
||||
return fmt.Sprintf("status:%q, code: %q, message: %q", e.Status, e.Code, e.Message)
|
||||
}
|
||||
|
||||
// NewError - a brand new error
|
||||
func NewError(code int, message string) *Error {
|
||||
return &Error{
|
||||
Status: 500,
|
||||
Code: code,
|
||||
Message: message,
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user