error

package module
v0.0.0-...-7bcf840 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

custom-error-go

license

A powerful, custom error package for Go

Detailed explanation: https://medium.com/codealchemist/error-handling-in-go-made-more-powerful-ce164c2384ee

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorCodeToUserMessages = map[ErrorCode]string{
	REQUEST_NOT_VALID: "Invalid Request. Please try again.",
	SQL_INSERT_ERROR:  "Something went wrong. Please try again.",
	SQL_UPDATE_ERROR:  "Something went wrong. Please try again.",
	SQL_FETCH_ERROR:   "Something went wrong. Please try again.",
}

Functions

This section is empty.

Types

type CustomError

type CustomError struct {
	// contains filtered or unexported fields
}

func NewCustomError

func NewCustomError(errorCode ErrorCode, error string) CustomError

func (CustomError) Error

func (c CustomError) Error() string

func (CustomError) ErrorCode

func (c CustomError) ErrorCode() ErrorCode

func (CustomError) ErrorMessage

func (c CustomError) ErrorMessage() string

func (CustomError) ErrorString

func (c CustomError) ErrorString() string

func (CustomError) Exists

func (c CustomError) Exists() bool

func (CustomError) Log

func (c CustomError) Log()

func (CustomError) LoggingParams

func (c CustomError) LoggingParams() map[string]interface{}

func (CustomError) ToError

func (c CustomError) ToError() error

func (CustomError) ToString

func (c CustomError) ToString() string

func (CustomError) UserMessage

func (c CustomError) UserMessage() string

func (CustomError) WithParam

func (c CustomError) WithParam(key string, val interface{}) CustomError

value param should not be a pointer

type ErrorCode

type ErrorCode string
const (
	REQUEST_NOT_VALID          ErrorCode = "REQUEST_NOT_VALID"
	SQL_INSERT_ERROR           ErrorCode = "SQL_INSERT_ERROR"
	SQL_UPDATE_ERROR           ErrorCode = "SQL_UPDATE_ERROR"
	SQL_FETCH_ERROR            ErrorCode = "SQL_FETCH_ERROR"
	API_URL_PARSING_ERROR      ErrorCode = "API_URL_PARSING_ERROR"
	API_REQUEST_CREATION_ERROR ErrorCode = "API_REQUEST_CREATION_ERROR"
	API_REQUEST_ERROR          ErrorCode = "API_REQUEST_ERROR"
	API_REQUEST_STATUS_ERROR   ErrorCode = "API_REQUEST_STATUS_ERROR"
	JSON_SERIALIZATION_ERROR   ErrorCode = "JSON_SERIALIZATION_ERROR"
	JSON_DESERIALIZATION_ERROR ErrorCode = "JSON_DESERIALIZATION_ERROR"
	FORM_SERIALIZATION_ERROR   ErrorCode = "FORM_SERIALIZATION_ERROR"
)

func (ErrorCode) ToString

func (e ErrorCode) ToString() string

Jump to

Keyboard shortcuts

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