forked from gsn/predictor
feat: predictions
This commit is contained in:
parent
42e7924be9
commit
11be8f351f
42 changed files with 2221 additions and 516 deletions
|
|
@ -23,13 +23,11 @@ func (e *ErrorCode) Error() string {
|
|||
return e.Message
|
||||
}
|
||||
|
||||
// IsErr checks if the given error is an ErrorCode
|
||||
func IsErr(err error) bool {
|
||||
_, ok := err.(*ErrorCode)
|
||||
return ok
|
||||
}
|
||||
|
||||
// AsErr converts error to ErrorCode if possible
|
||||
func AsErr(err error) (*ErrorCode, bool) {
|
||||
if err == nil {
|
||||
return nil, false
|
||||
|
|
@ -38,7 +36,6 @@ func AsErr(err error) (*ErrorCode, bool) {
|
|||
return errcode, ok
|
||||
}
|
||||
|
||||
// Join combines multiple errors into a single ErrorCode
|
||||
func Join(errs ...error) error {
|
||||
if len(errs) == 0 {
|
||||
return nil
|
||||
|
|
@ -66,7 +63,6 @@ func Join(errs ...error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Use the first error's status code, or default to 500
|
||||
statusCode := http.StatusInternalServerError
|
||||
if len(errs) > 0 {
|
||||
if errcode, ok := AsErr(errs[0]); ok {
|
||||
|
|
@ -77,7 +73,6 @@ func Join(errs ...error) error {
|
|||
return New(statusCode, strings.Join(messages, "; "), details...)
|
||||
}
|
||||
|
||||
// Wrap wraps an error with additional context
|
||||
func Wrap(err error, message string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue