77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
package assets
|
|
|
|
import "fmt"
|
|
|
|
//ErrAssetNotFound occurs when a asset is not found.
|
|
type ErrAssetNotFound struct{}
|
|
|
|
//Error returns error message
|
|
func (e *ErrAssetNotFound) Error() string {
|
|
return "asset not found"
|
|
}
|
|
|
|
//NewErrAssetNotFound occurs when a asset is not found.
|
|
func NewErrAssetNotFound() error {
|
|
return &ErrAssetNotFound{}
|
|
}
|
|
|
|
//ErrInvalidArgument occurs when an argument is invalid.
|
|
type ErrInvalidArgument struct {
|
|
argument string
|
|
message string
|
|
}
|
|
|
|
//Error returns error message
|
|
func (e *ErrInvalidArgument) Error() string {
|
|
return fmt.Sprintf("invalid argument: %s (%s)", e.argument, e.message)
|
|
}
|
|
|
|
//NewErrInvalidArgument occurs when an argument is invalid.
|
|
func NewErrInvalidArgument(argument string, message string) error {
|
|
return &ErrInvalidArgument{argument, message}
|
|
}
|
|
|
|
//ErrAssetRepositoryErr occurs when something in the asset repository went wrong.
|
|
type ErrAssetRepositoryErr struct {
|
|
message string
|
|
original error
|
|
}
|
|
|
|
//Error returns error message
|
|
func (e *ErrAssetRepositoryErr) Error() string {
|
|
return fmt.Sprintf("%s: %s", e.message, e.original.Error())
|
|
}
|
|
|
|
//NewErrAssetRepositoryErr occurs when something in the asset repository went wrong.
|
|
func NewErrAssetRepositoryErr(message string, original error) error {
|
|
return &ErrAssetRepositoryErr{message, original}
|
|
}
|
|
|
|
//ErrAuthFailed occurs when something in the auth client went wrong.
|
|
type ErrAuthFailed struct {
|
|
original error
|
|
}
|
|
|
|
//Error returns error message
|
|
func (e *ErrAuthFailed) Error() string {
|
|
return fmt.Sprintf("authentication failed: %s", e.original.Error())
|
|
}
|
|
|
|
//NewErrAuthFailed occurs when something in the auth client went wrong.
|
|
func NewErrAuthFailed(original error) error {
|
|
return &ErrAuthFailed{original}
|
|
}
|
|
|
|
//ErrUnauthorized occurs when a user is not found.
|
|
type ErrUnauthorized struct{}
|
|
|
|
//Error returns error message
|
|
func (e *ErrUnauthorized) Error() string {
|
|
return "unauthorized"
|
|
}
|
|
|
|
//NewErrUnauthorized occurs when a user is not found.
|
|
func NewErrUnauthorized() error {
|
|
return &ErrUnauthorized{}
|
|
}
|