error

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrorCodeAPICallFailure error code for API call failure
	ErrorCodeAPICallFailure = "Key_APICallFailure"
	// ErrorCodeCryptoFailure error code for encrypt / decrypt / hashing failure
	ErrorCodeCryptoFailure = "Key_CryptoFailure"
	// ErrorCodeDatabaseFailure error code for database falure
	ErrorCodeDatabaseFailure = "Key_DBQueryFailure"
	// ErrorCodeDuplicateValue error code for duplicate value
	ErrorCodeDuplicateValue = "Key_AlreadyExists"
	// ErrorCodeEmptyRequestBody error code for empty request body
	ErrorCodeEmptyRequestBody = "Key_EmptyRequestBody"
	// ErrorCodeHTTPCreateRequestFailure error code for http request creation failure
	ErrorCodeHTTPCreateRequestFailure = "Key_HTTPCreateRequestFailure"
	// ErrorCodeInvalidFormData error code for form parsing error
	ErrorCodeInvalidFormData = "Key_InvalidFormData"
	// ErrorCodeInternalError error code for internal error
	ErrorCodeInternalError = "Key_InternalError"
	// ErrorCodeInvalidFields error code for invalid fields
	ErrorCodeInvalidFields = "Key_InvalidFields"
	// ErrorCodeInvalidJSON error code for invalid JSON
	ErrorCodeInvalidJSON = "Key_InvalidJSON"
	// ErrorCodeInvalidPublicKey error code for invalid public cert
	ErrorCodeInvalidPublicKey = "Key_InvalidPublicKey"
	// ErrorCodeInvalidRequestPayload error code for invalid request payload
	ErrorCodeInvalidRequestPayload = "Key_InvalidRequestPayload"
	// ErrorCodeInvalidValue error code for invalid value
	ErrorCodeInvalidValue = "Key_InvalidValue"
	// ErrorCodeJSONMarshalFailure error code for json marshal failures
	ErrorCodeJSONMarshalFailure = "Key_JSONMarshalFailure"
	// ErrorCodeNotExists error code for not exists
	ErrorCodeNotExists = "Key_NotExists"
	// ErrorCodeReadWriteFailure error code for io error
	ErrorCodeReadWriteFailure = "Key_ReadWriteFailure"
	// ErrorCodeRequired error code for required fields
	ErrorCodeRequired = "Key_Required"
	// ErrorCodeStringExpected error code for string type
	ErrorCodeStringExpected = "Key_StringExpected"
)

NOTE: Please maintain in ascending order

Variables

This section is empty.

Functions

func IsUnexpectedError

func IsUnexpectedError(err error) bool

IsUnexpectedError returns whether the given error is an UnexpectedError

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns whether the given error is an ValidationError

Types

type APICallError added in v1.0.1

type APICallError interface {
	UnexpectedError
	GetAPIURL() string
	GetHTTPStatusCode() *int
	GetHTTPResponseBody() *string
}

APICallError represents an database query failure error interface

func NewAPICallError added in v1.0.1

func NewAPICallError(apiURL string, httpStatusCode *int, httpResponseBody *string, err error) APICallError

NewAPICallError creates a new API call error

type DatabaseError

type DatabaseError interface {
	UnexpectedError
	IsRecordNotFoundError() bool
}

DatabaseError represents an database query failure error interface

func NewDatabaseError

func NewDatabaseError(err error) DatabaseError

NewDatabaseError creates a new database error

type HTTPError

type HTTPError struct {
	HTTPStatus int
	ErrorKey   string
}

HTTPError Represent an error to be sent back on repsonse

func NewHTTPError

func NewHTTPError(err string, httpStatus int) HTTPError

NewHTTPError creates an new instance of HTTP Error

func (HTTPError) Error

func (err HTTPError) Error() string

Error returns the error string

type HTTPResourceNotFound

type HTTPResourceNotFound struct {
	ErrorKey      string `json:"errorKey"`
	ResourceName  string `json:"resourceName"`
	ResourceValue string `json:"resourceValue"`
}

HTTPResourceNotFound represents HTTP 404 error

func NewHTTPResourceNotFound

func NewHTTPResourceNotFound(resourceName, resourceValue string) HTTPResourceNotFound

NewHTTPResourceNotFound creates an new instance of HTTP Error

func (HTTPResourceNotFound) Error

func (e HTTPResourceNotFound) Error() string

Error returns the error string

type UnexpectedError

type UnexpectedError interface {
	Error() string
	GetErrorCode() string
	GetStackTrace() string
	GetCause() error
}

UnexpectedError represents an unexpected error interface

func NewCryptoError

func NewCryptoError(err error) UnexpectedError

NewCryptoError creates a new encryptions / decryptions error

func NewDataReadWriteError

func NewDataReadWriteError(err error) UnexpectedError

NewDataReadWriteError creates a new read write error

func NewUnexpectedError

func NewUnexpectedError(errCode string, err error) UnexpectedError

NewUnexpectedError creates a new unexpected error

type ValidationError

type ValidationError struct {
	ErrorKey string            `json:"errorKey"`
	Errors   map[string]string `json:"errors"`
}

ValidationError is an error indicating error in validations

func NewInvalidFieldsError

func NewInvalidFieldsError(failedFieldValidations map[string]string) ValidationError

NewInvalidFieldsError creates a new invalid fields validation Error. 'failedFieldValidations' - map key should be the name of the field and value should be the error code.

func NewInvalidRequestPayloadError

func NewInvalidRequestPayloadError(errorCode string) ValidationError

NewInvalidRequestPayloadError creates a new invalid request payload validation Error.

func NewValidationError

func NewValidationError(errKey string, failedValidations map[string]string) ValidationError

NewValidationError creates a new invalid fields validation Error.

func (ValidationError) Error

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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