Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // UnknownError represents a general undefined error. UnknownError = New("Unknown error") // NotImplemented indicates that a feature is not implemented. NotImplemented = New("Not implemented") // Unauthenticated indicates an authentication failure. // Authentication - Who are you? Unauthenticated = New("Failed auth") // Authorization - Are you allowed to do that? Unauthorized = New("Access Denied") // InvalidToken indicates an invalid authentication token. InvalidToken = New("Invalid token") // InvalidRequest indicates a malformed or invalid request. InvalidRequest = New("Invalid request") // InvalidData indicates a malformed or invalid data. InvalidData = New("Invalid data") // InvalidParameter indicates an invalid parameter in the request. InvalidParameter = New("Invalid parameter") // TooManyRequests indicates that the request rate limit has been exceeded. TooManyRequests = New("Too many requests") // InvalidHeader indicates an issue with an HTTP header. InvalidHeader = New("Invalid header") ServiceUnavailable = New("Service unavailable") // ItemNotFound indicates that a requested item could not be found. ItemNotFound = New("Item not found") // InternalError indicates an internal server error. InternalError = New("Internal server error") // ActionTimeout indicates that the action has timed out. ActionTimeout = New("Action timeout") )
Functions ¶
func Is ¶ added in v1.16.0
Is reports whether any error in err's tree matches target.
The tree consists of err itself, followed by the errors obtained by repeatedly calling its Unwrap() error or Unwrap() []error method. When err wraps multiple errors, Is examines err followed by a depth-first traversal of its children.
An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
An error type might provide an Is method so it can be treated as equivalent to an existing error. For example, if MyError defines
func (m MyError) Is(target error) bool { return target == fs.ErrExist }
then Is(MyError{}, fs.ErrExist) returns true. See syscall.Errno.Is for an example in the standard library. An Is method should only shallowly compare err and the target and not call [Unwrap] on either.
func New ¶ added in v1.7.1
New returns a formatted error message based on the given format and arguments.
Parameters:
- format: String that contains the error message with optional format verbs
- args: Optional arguments to be formatted according to the format string
Returns:
- error: Formatted error object containing the message
func ToStr ¶ added in v1.16.0
ToStr formats and returns an error string using the provided error format string and arguments.
Note: The method should be used by custom error is not a string type.
Parameters:
- format: Format string that may contain format specifiers
- args: Optional arguments to be formatted according to the format string
Returns:
- string: Formatted string with arguments substituted into format
Types ¶
type FileNotFound ¶
FileNotFound is used when a requested file is not found in the system
func (FileNotFound) Error ¶
func (f FileNotFound) Error() string
Error returns an error message indicating that the file was not found