Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHttpResponseParseData - response data is not valid. ErrHttpResponseParseData = mrerr.NewProto( "errHttpResponseParseData", mrerr.ErrorKindInternal, "response data is not valid") // ErrHttpFileUpload - the file with the specified key was not uploaded. ErrHttpFileUpload = mrerr.NewProto( "errHttpFileUpload", mrerr.ErrorKindUser, "the file with the specified key '{{ .key }}' was not uploaded") // ErrHttpMultipartFormFile - the file with the specified key cannot be processed. ErrHttpMultipartFormFile = mrerr.NewProto( "errHttpMultipartFormFile", mrerr.ErrorKindSystem, "the file with the specified key '{{ .key }}' cannot be processed") ErrHttpClientUnauthorized = mrerr.NewProto( "errHttpClientUnauthorized", mrerr.ErrorKindUser, "401. client is unauthorized") // ErrHttpAccessForbidden - 403. access forbidden. ErrHttpAccessForbidden = mrerr.NewProto( "errHttpAccessForbidden", mrerr.ErrorKindUser, "403. access forbidden") // ErrHttpResourceNotFound - 404. resource not found. ErrHttpResourceNotFound = mrerr.NewProto( "errHttpResourceNotFound", mrerr.ErrorKindUser, "404. resource not found") // ErrHttpRequestParseData - request body is not valid. ErrHttpRequestParseData = mrerr.NewProto( "errHttpRequestParseData", mrerr.ErrorKindInternal, "request body is not valid") // ErrHttpRequestParseParam - request param with key of type contains incorrect value. ErrHttpRequestParseParam = mrerr.NewProto( "errHttpRequestParseParam", mrerr.ErrorKindUser, "request param with key '{{ .key }}' of type '{{ .type }}' contains incorrect value '{{ .value }}'") // ErrHttpRequestParamEmpty - request param with key is empty. ErrHttpRequestParamEmpty = mrerr.NewProto( "errHttpRequestParamEmpty", mrerr.ErrorKindUser, "request param with key '{{ .key }}' is empty") // ErrHttpRequestParamMax - request param with key contains value greater then max. ErrHttpRequestParamMax = mrerr.NewProto( "errHttpRequestParamMax", mrerr.ErrorKindUser, "request param with key '{{ .key }}' contains value greater then max '{{ .max }}'") // ErrHttpRequestParamLenMax - request param with key has value length greater then max characters. ErrHttpRequestParamLenMax = mrerr.NewProto( "errHttpRequestParamLenMax", mrerr.ErrorKindUser, "request param with key '{{ .key }}' has value length greater then max '{{ .maxLength }}' characters") )
var ( // ErrInternal - internal error. ErrInternal = mrerr.NewProto( "errInternal", mrerr.ErrorKindInternal, "internal error") // ErrInternalNilPointer - unexpected nil pointer. ErrInternalNilPointer = mrerr.NewProto( "errInternalNilPointer", mrerr.ErrorKindInternal, "unexpected nil pointer") // ErrInternalTypeAssertion - invalid type assertion. ErrInternalTypeAssertion = mrerr.NewProto( "errInternalTypeAssertion", mrerr.ErrorKindInternal, "invalid type '{{ .type }}' assertion (value: {{ .value }})") // ErrInternalInvalidType - invalid type, expected. ErrInternalInvalidType = mrerr.NewProto( "errInternalInvalidType", mrerr.ErrorKindInternal, "invalid type '{{ .currentType }}', expected: '{{ .expectedType }}'") // ErrInternalKeyNotFoundInSource - key is not found in source. ErrInternalKeyNotFoundInSource = mrerr.NewProto( "errInternalKeyNotFoundInSource", mrerr.ErrorKindInternal, "key '{{ .key }}' is not found in source {{ .source }}") // ErrInternalFailedToOpen - failed to open object. ErrInternalFailedToOpen = mrerr.NewProto( "errInternalFailedToOpen", mrerr.ErrorKindInternal, "failed to open object") // ErrInternalFailedToClose - failed to close object. ErrInternalFailedToClose = mrerr.NewProto( "errInternalFailedToClose", mrerr.ErrorKindInternal, "failed to close object") // ErrInternalValueLenMax - value has length greater then max characters. ErrInternalValueLenMax = mrerr.NewProto( "errInternalValueLenMax", mrerr.ErrorKindInternal, "value has length '{{ .curLength }}' greater then max '{{ .maxLength }}' characters") // ErrInternalValueNotMatchRegexpPattern - specified value does not match regexp pattern. ErrInternalValueNotMatchRegexpPattern = mrerr.NewProto( "errInternalValueNotMatchRegexpPattern", mrerr.ErrorKindInternal, "specified value '{{ .value }}' does not match regexp pattern '{{ .pattern }}'") )
var ( // ErrStorageConnectionIsAlreadyCreated - connection is already created. ErrStorageConnectionIsAlreadyCreated = mrerr.NewProto( "errStorageConnectionIsAlreadyCreated", mrerr.ErrorKindInternal, "connection '{{ .name }}' is already created") // ErrStorageConnectionIsNotOpened - connection is not opened. ErrStorageConnectionIsNotOpened = mrerr.NewProto( "errStorageConnectionIsNotOpened", mrerr.ErrorKindInternal, "connection '{{ .name }}' is not opened") // ErrStorageConnectionFailed - connection is failed. ErrStorageConnectionFailed = mrerr.NewProto( "errStorageConnectionFailed", mrerr.ErrorKindSystem, "connection '{{ .name }}' is failed") // ErrStorageQueryFailed - query is failed. ErrStorageQueryFailed = mrerr.NewProto( "errStorageQueryFailed", mrerr.ErrorKindInternal, "query is failed") // ErrStorageFetchDataFailed - fetching data is failed. ErrStorageFetchDataFailed = mrerr.NewProto( "errStorageFetchDataFailed", mrerr.ErrorKindInternal, "fetching data is failed") // ErrStorageNoRowFound - no row found. ErrStorageNoRowFound = mrerr.NewProto( "errStorageNoRowFound", mrerr.ErrorKindInternal, "no row found") // ErrStorageRowsNotAffected - rows not affected. ErrStorageRowsNotAffected = mrerr.NewProto( "errStorageRowsNotAffected", mrerr.ErrorKindInternal, "rows not affected") )
var ( // ErrUseCaseOperationFailed - operation failed. ErrUseCaseOperationFailed = mrerr.NewProto( "errUseCaseOperationFailed", mrerr.ErrorKindInternal, "operation failed") ErrUseCaseTemporarilyUnavailable = mrerr.NewProto( "errUseCaseTemporarilyUnavailable", mrerr.ErrorKindSystem, "system is temporarily unavailable") // ErrUseCaseIncorrectInputData - data is incorrect. ErrUseCaseIncorrectInputData = mrerr.NewProto( "errUseCaseIncorrectInputData", mrerr.ErrorKindInternal, "{{ .key }}={{ .data }} is incorrect") // ErrUseCaseEntityNotFound - entity not found. ErrUseCaseEntityNotFound = mrerr.NewProto( "errUseCaseEntityNotFound", mrerr.ErrorKindUser, "entity not found") // ErrUseCaseEntityNotAvailable - entity is not available. ErrUseCaseEntityNotAvailable = mrerr.NewProto( "errUseCaseEntityNotAvailable", mrerr.ErrorKindUser, "entity is not available") // ErrUseCaseEntityVersionInvalid - entity version is invalid. ErrUseCaseEntityVersionInvalid = mrerr.NewProto( "errUseCaseEntityVersionInvalid", mrerr.ErrorKindUser, "entity version is invalid") // ErrUseCaseSwitchStatusRejected - switching from status to status is rejected. ErrUseCaseSwitchStatusRejected = mrerr.NewProto( "errUseCaseSwitchStatusRejected", mrerr.ErrorKindUser, "switching from '{{ .statusFrom }}' to '{{ .statusTo }}' is rejected") // ErrUseCaseInvalidFile - file is invalid. ErrUseCaseInvalidFile = mrerr.NewProto( "errUseCaseInvalidFile", mrerr.ErrorKindUser, "file is invalid") )
Functions ¶
func CastToAppError ¶ added in v0.18.0
CastToAppError - приводит указанную ошибку к AppError или если это невозможно, то оборачивает её в UnexpectedInternal ошибку, затем возвращает результат. (при этом исключается генерация ID и стека вызовов для ошибки). Используется на поздних этапах обработки ошибок.
func IsUnexpectedError ¶ added in v0.18.0
IsUnexpectedError - проверяется, является ли указанная ошибка необработанной. Такая ошибка может появиться только в результате вызова метода CastToAppError.
func PrepareError ¶ added in v0.18.0
PrepareError - приводит указанную ошибку к AppError или если это невозможно, то оборачивает её в Internal ошибку, затем возвращает результат. (при этом происходит генерация ID и стека вызовов для ошибки, если это необходимо). Вызываться должно как можно ближе к тому месту, где произошла непосредственно ошибка.
Types ¶
type ErrorHandler ¶ added in v0.18.0
ErrorHandler - обработчик ошибок.
type UsecaseErrorWrapper ¶ added in v0.18.0
type UsecaseErrorWrapper interface { IsNotFoundError(err error) bool WrapErrorFailed(err error, source string) error WrapErrorNotFoundOrFailed(err error, source string) error WrapErrorEntityFailed(err error, entityName string, entityData any) error WrapErrorEntityNotFoundOrFailed(err error, entityName string, entityData any) error }
UsecaseErrorWrapper - помощник для оборачивания UseCase ошибок.