server-go/web/error.go

26 lines
326 B
Go
Raw Normal View History

2018-04-06 04:06:05 +00:00
package web
2018-04-06 05:50:20 +00:00
import (
cuc "git.loafle.net/commons/util-go/context"
)
const (
ErrorKey = cuc.ContextKey("ErrorKey")
)
func NewError(code int, cause error) *Error {
return &Error{
Code: code,
Cause: cause,
2018-04-06 04:06:05 +00:00
}
}
2018-04-06 05:50:20 +00:00
type Error struct {
Code int
Cause error
2018-04-06 04:06:05 +00:00
}
2018-04-06 05:50:20 +00:00
func (e *Error) Error() string {
return e.Cause.Error()
2018-04-06 04:06:05 +00:00
}