29 lines
538 B
Go
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")
|
|
)
|