errors

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	SuccessCode          int64 = 0
	InvalidSignatureCode int64 = 1
	InvalidTaxID         int64 = 3
	ApprovalRequired     int64 = 4
	UnhandledException   int64 = 5
	InvalidSerial        int64 = 6
	InvalidClientHeader  int64 = 7
	InvalidCertificate   int64 = 8
)
View Source
const (
	SuccessMessage      = "Success"
	InvalidSignatureMsg = "Invalid Signature. Signature generated not in correct format or" +
		" Signature generated with missing nodes or signature generated with empty lines in XML."
	InvalidTaxIDMsg       = "Invalid TIN. TIN specified with dash or wrong TIN specified."
	ApprovalRequiredMsg   = "VFD Registration Approval required. Request posted without Client details, which is WEBAPI."
	UnhandledExceptionMsg = "Unhandled Exception. Contact TRA for further troubleshooting."
	InvalidSerialMsg      = "Invalid Serial or Serial not Registered to Web API/TIN." +
		" CERTKEY is not registered to TIN sending registration request. Use only TIN and CERTKEY provided by TRA."
	InvalidClientHeaderMsg = "Invalid client header. Wrong client value specified."
	InvalidCertificateMsg  = "Wrong Certificate used to Register Web API. Wrong certificate used."
)

Variables

This section is empty.

Functions

func CheckNetworkError

func CheckNetworkError(ctx context.Context, prefix string, err error) error

CheckNetworkError checks if the errors is about network and returns a NetworkError. An errors are considered a network error if it is a net.Error, context.Canceled or context.DeadlineExceeded. or just a context error.

Example
err := &NetworkError{
	Err:     fmt.Errorf("failed to connect to server"),
	Message: "failed to connect to server",
}

errFinal := CheckNetworkError(context.Background(), "test", err)
fmt.Println(errFinal)
Output:
test: failed to connect to server: failed to connect to server

func ParseErrorCode

func ParseErrorCode(code int64) string

ParseErrorCode parses the error code and returns the corresponding error message.

Types

type Error

type Error struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Err     string `json:"error,omitempty"`
}

func New

func New(code, message string, err string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type NetworkError

type NetworkError struct {
	Err     error
	Message string
}

NetworkError is returned when there is an error in the network.

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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