aicra/api/error.go

22 lines
494 B
Go
Raw Permalink Normal View History

package api
import (
"fmt"
)
// Err represents an http response error following the api format.
// These are used by the services to set the *execution status*
// directly into the response as JSON alongside response output fields.
type Err struct {
// error code (unique)
Code int `json:"code"`
// error small description
Reason string `json:"reason"`
// associated HTTP status
2021-05-18 09:10:12 +00:00
Status int `json:"-"`
}
func (e Err) Error() string {
return fmt.Sprintf("[%d] %s", e.Code, e.Reason)
}