Documentation ¶
Index ¶
- Constants
- func IsUnexpectedError(err error) bool
- func IsValidationError(err error) bool
- type APIClientError
- type APIClientErrorImpl
- func (e APIClientErrorImpl) Error() string
- func (e *APIClientErrorImpl) GetAPIURL() string
- func (e APIClientErrorImpl) GetCause() error
- func (e APIClientErrorImpl) GetErrorCode() string
- func (e *APIClientErrorImpl) GetHTTPResponseBody() *string
- func (e *APIClientErrorImpl) GetHTTPStatusCode() *int
- func (e APIClientErrorImpl) GetStackTrace() string
- type DatabaseError
- type HTTPError
- type HTTPResourceNotFound
- type UnexpectedError
- type ValidationError
Constants ¶
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 ¶
IsUnexpectedError returns whether the given error is an UnexpectedError
func IsValidationError ¶
IsValidationError returns whether the given error is an ValidationError
Types ¶
type APIClientError ¶ added in v1.0.18
type APIClientError interface { UnexpectedError GetAPIURL() string GetHTTPStatusCode() *int GetHTTPResponseBody() *string }
APIClientError represents an database query failure error interface
func NewAPIClientError ¶ added in v1.0.18
func NewAPIClientError(apiURL string, httpStatusCode *int, httpResponseBody *string, err error) APIClientError
NewAPIClientError creates a new API call error
type APIClientErrorImpl ¶ added in v1.0.18
type APIClientErrorImpl struct {
// contains filtered or unexported fields
}
func (APIClientErrorImpl) Error ¶ added in v1.0.18
func (e APIClientErrorImpl) Error() string
Error returns the error string
func (*APIClientErrorImpl) GetAPIURL ¶ added in v1.0.18
func (e *APIClientErrorImpl) GetAPIURL() string
GetAPIURL gets API URL
func (APIClientErrorImpl) GetCause ¶ added in v1.0.18
func (e APIClientErrorImpl) GetCause() error
GetErrCode returns the error code
func (APIClientErrorImpl) GetErrorCode ¶ added in v1.0.18
func (e APIClientErrorImpl) GetErrorCode() string
GetErrCode returns the error code
func (*APIClientErrorImpl) GetHTTPResponseBody ¶ added in v1.0.18
func (e *APIClientErrorImpl) GetHTTPResponseBody() *string
GetHTTPResponseBody gets http status code
func (*APIClientErrorImpl) GetHTTPStatusCode ¶ added in v1.0.18
func (e *APIClientErrorImpl) GetHTTPStatusCode() *int
GetHttpStatusCode gets http status code
func (APIClientErrorImpl) GetStackTrace ¶ added in v1.0.18
func (e APIClientErrorImpl) GetStackTrace() string
GetStackTrace returns the error stack trace
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 ¶
HTTPError Represent an error to be sent back on repsonse
func NewHTTPError ¶
NewHTTPError creates an new instance of HTTP Error
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