mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-02 09:39:35 -06:00
29 lines
460 B
Go
29 lines
460 B
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type Err struct {
|
|
Status int `json:"status"`
|
|
Code string `json:"code"`
|
|
Details string `json:"details"`
|
|
}
|
|
|
|
func New(httpStatus int, code, details string) error {
|
|
return &Err{
|
|
Status: httpStatus,
|
|
Code: code,
|
|
Details: details,
|
|
}
|
|
}
|
|
|
|
func (e *Err) Error() string {
|
|
return fmt.Sprintf("%d %s (%s)", e.Status, e.Code, e.Details)
|
|
}
|
|
|
|
func Is(err, target error) bool {
|
|
return errors.Is(err, target)
|
|
}
|