stderr

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_CODE_INVALID_HEADER    = "X0"
	ERROR_CODE_ACCESS_PERMISSION = "X1"
	ERROR_CODE_PARAMETER         = "01" // 200, mostly in controller when failed in validation rules
	ERROR_CODE_DATA_NOT_FOUND    = "02"
	ERROR_CODE_INVALID_RULE      = "03"
	ERROR_CODE_THIRD_PARTY       = "04"
	ERROR_CODE_WAITING_STATUS    = "05"
	ERROR_CODE_UNSUPPORTED       = "06"
	ERROR_CODE_SYSTEM            = "99" // 200, e.g. failed in connection
)

The standard error codes that is used in brispot.

View Source
const (
	ERROR_DESC_INVALID_HEADER = "Header request tidak valid"
	ERROR_DESC_PERMISSION     = "Akses tidak diijinkan"
	ERROR_DESC_PARAMETER      = "Parameter tidak sesuai"
	ERROR_DESC_DATA_NOT_FOUND = "Data tidak ditemukan"
	ERROR_DESC_INVALID_RULE   = "Validasi rule tidak terpenuhi"
	ERROR_DESC_THIRD_PARTY    = "Service ThirdParty bermasalah"
	ERROR_DESC_WAITING_STATUS = "Masih proses harap tunggu"
	ERROR_DESC_UNSUPPORTED    = "Mekanisme tidak disupport"
	ERROR_DESC_SYSTEM         = "Runtime error happens"
)

The standard error description that is used in brispot.

Variables

This section is empty.

Functions

func Err

func Err(code string, msg string, httpCode int) error

Err set std error by given error code, message and any desired http code.

Each value can be retrieved by helper func such as GetCode, GetMsg, GetMeta.

func ErrDataNotFound

func ErrDataNotFound() error

ErrDataNotFound error similar with ErrNotFound but use message 'data tidak ditemukan'.

func ErrInvHeader

func ErrInvHeader(msg ...string) error

ErrInvHeader error invalid header, this may commonly be used in spotlibs gateway.

This error will set the response http code to 400 via stdresp.WithErr.

func ErrInvRule

func ErrInvRule(msg ...string) error

ErrInvRule any process that does not meet with the requirement set in the usecase layer.

func ErrNotFound

func ErrNotFound(msg ...string) error

ErrNotFound error when the 'expected' data not found, this may exist in both usecase and repository layer, or even in the service layer.

func ErrParam

func ErrParam(msg ...string) error

ErrParam error in validation such as in the parameter input coming from request.

func ErrPermission

func ErrPermission(msg ...string) error

ErrPermission error permission denied, this may commonly be used in api gateway, or any other middleware that need to return non-200 http status code.

This error will set the response http code to 403 via stdresp.WithErr.

func ErrRuntime

func ErrRuntime(msg ...string) error

ErrRuntime unexpected error that may occur in the runtime.

e.g. error when doing json Marshal/Unmarshal.

func ErrThirdParty

func ErrThirdParty(msg ...string) error

ErrThirdParty error triggered by surrounding service. It's up to developer whether they should propagate the 'error' from surrounding to the response, or to masking it and mark it as 3rd-party error.

func ErrUnsupported

func ErrUnsupported(msg ...string) error

ErrUnsupported error when the incoming request can not be supported.

e.g. when incoming request with method GET but the endpoint expect POST.

func ErrValidation

func ErrValidation(msg string, validation []string) error

ErrValidation error in validation, it's not recommended to be used directly.

Currently, this func only used by validation pkg.

func ErrWaiting

func ErrWaiting(msg ...string) error

ErrWaiting error when there is still process occurring in the background.

func GetCode

func GetCode(e error) string

GetCode get the error code if the given error if it's error coming from this stderr pkg, otherwise will return the default ERROR_CODE_SYSTEM.

func GetHttpCode

func GetHttpCode(e error) int

GetHttpCode get the http status code reside in the error. Will return the correct http code if the error coming from this stderr pkg, otherwise will return 500.

func GetMeta

func GetMeta(e error) any

GetMeta get the error metadata if the given error is coming from this stderr pkg, otherwise will return nil.

func GetMsg

func GetMsg(e error) string

GetMsg get the error message if the given error if it's error coming from this pkg, otherwise will return the default ERROR_DESC_SYSTEM.

func GetStackTrace

func GetStackTrace(e error) string

GetStackTrace get the error stack trace if the given error if it's error coming from this pkg, otherwise will return the default ERROR_DESC_SYSTEM.

func GetValidationErrorMsg

func GetValidationErrorMsg(e error) []string

GetValidationErrorMsg return the validation message injected in ErrValidation, otherwise will just return nil.

func IsErrNotFound

func IsErrNotFound(e error) bool

IsErrNotFound return true if the given error is created using ErrNotFound or ErrDataNotFound.

func IsStdError

func IsStdError(e error) bool

IsStdError check whether given error is created using this stderr pkg.

func RemoveDebugDepthLevel

func RemoveDebugDepthLevel()

RemoveDebugDepthLevel remove the depth level so that error will print all captured stack trace.

func SetDebugDepthLevel

func SetDebugDepthLevel(lvl int)

SetDebugDepthLevel set the depth level of line captured in the debug.

Types

This section is empty.

Jump to

Keyboard shortcuts

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