errors

package
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2025 License: MIT Imports: 1 Imported by: 16

README

Errors

Error types

Usage

Quick usage

import "github.com/gflydev/core/errors"

panic(errors.ItemNotFound)

Documentation

Index

Constants

View Source
const (
	// UnknownError represents a general undefined error.
	UnknownError = Error("Unknown error")

	// NotImplemented indicates that a feature is not implemented.
	NotImplemented = Error("Not implemented")

	// Unauthenticated indicates an authentication failure.
	// Authentication - Who are you?
	Unauthenticated = Error("Failed auth")

	// Unauthorized (Forbidden) indicates a failed authorization attempt.
	// Authorization - Are you allowed to do that?
	Unauthorized = Error("Access Denied")

	// InvalidToken indicates an invalid authentication token.
	InvalidToken = Error("Invalid token")

	// InvalidRequest indicates a malformed or invalid request.
	InvalidRequest = Error("Invalid request")

	// InvalidData indicates a malformed or invalid data.
	InvalidData = Error("Invalid data")

	// InvalidParameter indicates an invalid parameter in the request.
	InvalidParameter = Error("Invalid parameter")

	// TooManyRequests indicates that the request rate limit has been exceeded.
	TooManyRequests = Error("Too many requests")

	// InvalidHeader indicates an issue with an HTTP header.
	InvalidHeader = Error("Invalid header")

	// ServiceUnavailable indicates that the service is unavailable.
	ServiceUnavailable = Error("Service unavailable")

	// ItemNotFound indicates that a requested item could not be found.
	ItemNotFound = Error("Item not found")

	// InternalError indicates an internal server error.
	InternalError = Error("Internal server error")

	// ActionTimeout indicates that the action has timed out.
	ActionTimeout = Error("Action timeout")
)

Variables

This section is empty.

Functions

func New added in v1.7.1

func New(format string, args ...any) error

New returns a formatted error message based on the given format and arguments.

Types

type Error

type Error string

Error type represents a string-based error.

func (Error) Error

func (e Error) Error() string

Error returns the error message for the Error type.

type FileNotFound

type FileNotFound struct {
	FileName string `json:"fileName"`
	Path     string `json:"path"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL