errorHandler

package
v0.0.0-...-81c5462 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoEligibilityError = MiddlewareError{
	"FLM601",
	"No data to compute loan eligibility for user.",
}

NoEligibilityError User is not eligible for loan

Functions

func Cause

func Cause(err error) error

Cause returns the original error of a traceable error If the error is not traceable, it returns itself

func CustomError

func CustomError(c *gin.Context, httpStatusCode int, msg string, errorCode string)

CustomError returns an error message without reporting to sentry

func CustomErrorJSON

func CustomErrorJSON(c *gin.Context, httpStatusCode int, errJSON map[string]interface{})

CustomErrorJSON returns a JSON without reporting to sentry

func CustomErrorSentry

func CustomErrorSentry(c *gin.Context, httpStatusCode int, msg string, err error, errorCode string)

CustomErrorSentry returns an error message after reporting to sentry (if environment is not local)

func Recovery

func Recovery(c *gin.Context, httpStatusCode int)

Recovery handles the panic happening on any function, this is to be called by defer in functions

func RecoveryNoResponse

func RecoveryNoResponse()

RecoveryNoResponse handles the panic happening on any function, this is to be called by defer in functions

func ReportToSentry

func ReportToSentry(c *gin.Context, err error)

func StackTrace

func StackTrace(err error) string

StackTrace returns the stack trace with given error If the error is not traceable, empty string is returned

func Wrap

func Wrap(err error) error

Wrap wraps an error into a traceable error. If the wrapped error is traceable, do nothing. If the wrapped error is not traceable, record the stack trace.

Types

type MiddlewareError

type MiddlewareError struct {
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

MiddlewareError represet error codes

Jump to

Keyboard shortcuts

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