predictor/internal/pkg/errcodes/errcodes.go
2025-06-22 22:36:10 +03:00

29 lines
538 B
Go

package errcodes
import (
"net/http"
"strings"
)
type ErrorCode struct {
StatusCode int
Message string
Details string
}
func New(statusCode int, message string, details ...string) *ErrorCode {
return &ErrorCode{
StatusCode: statusCode,
Message: message,
Details: strings.Join(details, " "),
}
}
func (e *ErrorCode) Error() string {
return e.Message
}
var (
ErrNoDataset = New(http.StatusNotFound, "no grib dataset found")
ErrOutOfBounds = New(http.StatusBadRequest, "requested time is out of bounds")
)