drone/internal/api/render/errors.go
2022-08-09 12:37:37 -07:00

34 lines
883 B
Go

// Copyright 2021 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package render
var (
// ErrInvalidToken is returned when the api request token is invalid.
ErrInvalidToken = New("Invalid or missing token")
// ErrUnauthorized is returned when the user is not authorized.
ErrUnauthorized = New("Unauthorized")
// ErrForbidden is returned when user access is forbidden.
ErrForbidden = New("Forbidden")
// ErrNotFound is returned when a resource is not found.
ErrNotFound = New("Not Found")
)
// Error represents a json-encoded API error.
type Error struct {
Message string `json:"message"`
}
func (e *Error) Error() string {
return e.Message
}
// New returns a new error message.
func New(text string) error {
return &Error{Message: text}
}