Files
phylum/server/internal/api/errors/errors.go
2024-07-31 19:23:32 -07:00

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)
}