envelope

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package envelope provides custom error types and utility functions for API error handling.

Index

Constants

View Source
const (
	GeneralError      = "GeneralException"
	PermissionError   = "PermissionException"
	InputError        = "InputException"
	DataError         = "DataException"
	NetworkError      = "NetworkException"
	NotFoundError     = "NotFoundException"
	ConflictError     = "ConflictException"
	UnauthorizedError = "UnauthorizedException"
)

API errors.

Variables

This section is empty.

Functions

func NewError

func NewError(etype string, message string, data interface{}) error

NewError creates and returns a new instance of Error with custom error metadata.

func NewErrorWithCode

func NewErrorWithCode(etype string, code int, message string, data interface{}) error

NewErrorWithCode creates and returns a new instance of Error with custom error metadata and an HTTP status code.

Types

type Error

type Error struct {
	Code      int         // HTTP status code.
	ErrorType string      // Type of the error.
	Message   string      // Error message.
	Data      interface{} // Additional data related to the error.
}

Error is the error type used for all API errors.

func (Error) Error

func (e Error) Error() string

Error returns the error message and satisfies the Go error interface.

type PageResults

type PageResults struct {
	Results    interface{} `json:"results"`
	Total      int         `json:"total"`
	PerPage    int         `json:"per_page"`
	TotalPages int         `json:"total_pages"`
	Page       int         `json:"page"`
}

PageResults is a generic struct for paginated results.

Jump to

Keyboard shortcuts

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