Documentation ¶
Index ¶
- func Equals(left, right error) bool
- func Log(log *zap.SugaredLogger, err error)
- func NewError(err error, msg string, code Code) error
- func NewFailure(err error, f Failure) error
- func NewRequestValidationFailure(desc string, data map[string]interface{}) error
- func NewResponseValidationFailure(desc string, data map[string]interface{}) error
- func NewToolkitFailure(err error, desc string) error
- type Class
- type Code
- type CustomError
- type Error
- type Failure
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFailure ¶
NewFailure is constructor for failure custom errors.
func NewRequestValidationFailure ¶
NewRequestValidationFailure is constructor for request validation failure custom errors.
func NewResponseValidationFailure ¶
NewResponseValidationFailure is constructor for response validation failure custom errors.
func NewToolkitFailure ¶
NewToolkitFailure is constructor for toolkit failure custom errors.
Types ¶
type Code ¶
type Code uint32
Code is type for error code.
const ( // DefaultErrorCode is DefaultError code. DefaultErrorCode Code = 5000 // PostgreSQLErrorCode is PostgreSQLError code. PostgreSQLErrorCode Code = 5001 // RedisErrorCode is RedisError code. RedisErrorCode Code = 5002 // ToolkitErrorCode is ToolkitError code. ToolkitErrorCode Code = 5003 // CryptoGenerationErrorCode is error code for generation crypto. CryptoGenerationErrorCode Code = 5004 // CryptoEncryptErrorCode is encrypt error code. CryptoEncryptErrorCode Code = 5005 // CryptoDecryptErrorCode is decrypt error code. CryptoDecryptErrorCode Code = 5006 // DefaultCryptoErrorCode is default crypto error code. DefaultCryptoErrorCode Code = 5007 // RSAKeyFilesNotFoundErrorCode is RSAKeyFilesNotFoundError code RSAKeyFilesNotFoundErrorCode Code = 5008 // NotImplementedErrorCode is NotImplementedError code. NotImplementedErrorCode Code = 5011 OAuthManagementAPIServiceUnavailableErrorCode Code = 5031 UserManagementAPIServiceUnavailableErrorCode Code = 5032 ColangAPIServiceUnavailableErrorCode Code = 5033 WorldAPIServiceUnavailableErrorCode Code = 5034 AdminAPIServiceUnavailableErrorCode Code = 5035 SecretsManagementAPIServiceUnavailableErrorCode Code = 5036 // RequestValidationFailureCode is RequestValidationFailure code. RequestValidationFailureCode Code = 4001 // ResponseValidationFailureCode is ResponseValidationFailure code. ResponseValidationFailureCode Code = 4002 // OAuthManagementAPIBadRequestCode is OAuthManagementAPIBadRequest code. OAuthManagementAPIBadRequestCode Code = 4003 // UserManagementAPIBadRequestCode is UserManagementAPIBadRequest code. UserManagementAPIBadRequestCode Code = 4004 // ColangAPIServiceBadRequestCode is ColangAPIServiceBadRequest code. ColangAPIServiceBadRequestCode Code = 4005 // WorldAPIServiceBadRequestCode is WorldAPIServiceBadRequest code. WorldAPIServiceBadRequestCode Code = 4006 // AdminAPIServiceBadRequestCode is AdminAPIServiceBadRequest code. AdminAPIServiceBadRequestCode Code = 4007 // SecretsManagementAPBadRequestCode is SecretsManagementAPBadRequest code. SecretsManagementAPBadRequestCode Code = 4008 // TokenIsInvalidFailureCode is TokenIsInvalidFailure code. TokenIsInvalidFailureCode Code = 4011 // TokenIsExpiredFailureCode is TokenIsExpiredFailure code. TokenIsExpiredFailureCode Code = 4012 // IncorrectTokenFormatFailureCode is IncorrectTokenFormat code. IncorrectTokenFormatFailureCode Code = 4013 // RoleForbiddenFailureCode is RoleForbiddenFailure code. RoleForbiddenFailureCode Code = 4031 // EntityNotFoundFailureCode is EntityNotFoundFailure code. EntityNotFoundFailureCode Code = 4041 // HTTPMethodNotAllowedFailureCode is HTTPMethodNotAllowedFailure code. HTTPMethodNotAllowedFailureCode Code = 4051 // EntityAlreadyExistsFailureCode is EntityAlreadyExistsFailure code. EntityAlreadyExistsFailureCode Code = 4091 // ExtractIPAddressFromRequestFailureCode is ExtractIPAddressFromRequestFailure code. ExtractIPAddressFromRequestFailureCode Code = 4003 )
type CustomError ¶
type CustomError struct { Class Class `json:"class"` Fail Failure `json:"failure"` Err Error `json:"error"` ExtendedErr *CustomError }
CustomError is union of error & failure.
func Cast ¶
func Cast(err error) *CustomError
Cast cases error into *CustomError. If input is not *CustomError it will creates new *CustomError.
func CastStrict ¶
func CastStrict(err error) *CustomError
CastStrict cases error into *CustomError. If input is not *CustomError it will returns <nil>.
func (*CustomError) Error ¶
func (ce *CustomError) Error() string
Error is method that allows *CustomError matches with error interface.
type Failure ¶
type Failure struct { Code Code `json:"code"` Message string `json:"message"` Description string `json:"description"` StatusCode int `json:"status_code" desc:"StatusCode is HTTP status code"` Data map[string]interface{} `json:"data"` }
Failure is struct that represents error with status code 4XX. It is expected error.