serviceerror

package
v0.0.0-...-fd201ba Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnypbNew = anypb.New

Functions

func ConvertToGrpcError

func ConvertToGrpcError(serviceErr *ServiceError) error

func ExtractFromGrpcError

func ExtractFromGrpcError(err error) error

Types

type Error

type Error interface {
	GetErrorMessage() ErrorMessage
	GetAttributes() map[string]interface{}
	Error() string
}

type ErrorMessage

type ErrorMessage string
var (
	// General
	ServerError        ErrorMessage = "errors.serverError"
	ServiceUnavailable ErrorMessage = "errors.serviceIsUnavailable"
	PermissionDenied   ErrorMessage = "errors.permissionDenied"
	RecordNotFound     ErrorMessage = "errors.recordNotFound"
	Unauthorized       ErrorMessage = "errors.unauthorized"
	IsNotDeletable     ErrorMessage = "errors.isNotDeletable"
	NoRowsEffected     ErrorMessage = "errors.noRowsEffected"
	FailedSendEmail    ErrorMessage = "errors.failedSendEmail"

	// User
	UserIsBanned      ErrorMessage = "errors.userIsBanned"
	UserInActive      ErrorMessage = "errors.userInActive"
	UserUnVerified    ErrorMessage = "errors.userUnVerified"
	EmailRegistered   ErrorMessage = "errors.emailRegistered"
	CredentialInvalid ErrorMessage = "errors.credentialInvalid"
	UserLogout        ErrorMessage = "errors.userLogout"
	PasswordIsNull    ErrorMessage = "errors.passwordIsNull"

	// OTP
	InvalidOTP ErrorMessage = "errors.invalidOTP"
	OTPExpired ErrorMessage = "errors.OTPExpired"

	// Token
	InvalidToken ErrorMessage = "errors.invalidToken"
	TokenExpired ErrorMessage = "errors.tokenExpired"

	// Validation
	InvalidRequestBody ErrorMessage = "errors.invalidRequestBody"

	// Role
	RoleExisted ErrorMessage = "errors.roleExisted"

	// TOTP
	InvalidTOTPCode ErrorMessage = "errors.invalidTOTPCode"
	TOTPNotEnrolled ErrorMessage = "errors.totpNotEnrolled"
)

type ServiceError

type ServiceError struct {
	// contains filtered or unexported fields
}

func New

func New(msg ErrorMessage, attrs ...map[string]interface{}) *ServiceError

func NewServerError

func NewServerError() *ServiceError

func (ServiceError) Error

func (r ServiceError) Error() string

func (ServiceError) GetAttributes

func (r ServiceError) GetAttributes() map[string]interface{}

func (ServiceError) GetErrorMessage

func (r ServiceError) GetErrorMessage() ErrorMessage

Jump to

Keyboard shortcuts

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