Documentation ¶
Index ¶
Constants ¶
const ( HealthStatusOK = "ok" HealthStatusWarning = "warning" HealthStatusError = "error" )
Variables ¶
var (
ErrNoRecords = errors.New("no records")
)
Functions ¶
func ErrorMessage ¶
ErrorMessage returns the human-readable message of the error, if available. Otherwise returns a generic error message.
func IsNotFoundError ¶
IsNotFoundError returns if the provided error is related to no records found.
func IsValidationError ¶
IsValidationError checks if the provided error is related to validation.
func WrappedErrors ¶
WrappedErrors returns the wrapped validation errors. If err is not a validation error, nil is returned.
Types ¶
type Error ¶
Error defines a standard application error.
func (*Error) Error ¶
Error returns the error string of the first wrapped error. It returns the human-readable message if the wrapped error is nil. If receiver is nil, an empty string is returned.
type Health ¶
type Health struct { Name string `json:"name"` Status string `json:"status"` // ok|warning|error Core bool `json:"core"` // true for core dependencies LatencyMs int64 `json:"latency_ms"` Data struct { Message string `json:"message,omitempty"` Code int `json:"code,omitempty"` // remote HTTP status code } `json:"data"` }
type UserRepository ¶
type UserRepository interface { Ping(ctx context.Context) error FetchAll(ctx context.Context) ([]User, error) FetchByID(ctx context.Context, userID int) (*User, error) Add(ctx context.Context, name string) (int, error) }
UserRepository should be implemented to get access to the data store.
type ValidationError ¶
ValidationError defines a standard application error.
func (*ValidationError) Error ¶
func (err *ValidationError) Error() string
Error returns the error field and message as a combined string.