exception

package
v0.0.0-...-7efc56f Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RequiredTag         = "required"
	EqFieldTag          = "eqfield"
	MinTag              = "min"
	MaxTag              = "max"
	Base64Tag           = "base64"
	EmailTag            = "email"
	HiraganaTag         = "hiragana"
	PasswordTag         = "password"
	UniqueTag           = "unique"
	LessThanTag         = "lt"
	LessThanEqualTag    = "lte"
	GreaterThanTag      = "gt"
	GreaterThanEqualTag = "gte"
	OneOfTag            = "oneof"
)

バリデーションタグ

View Source
const (
	RequiredMessage         = "is required"
	EqFieldMessage          = "does not match %s"
	MinMessage              = "must be at least %s characters"
	MaxMessage              = "must be at %s or less characters"
	Base64Message           = "should be in base64 format"
	EmailMessage            = "should be in email format"
	HiraganaMessage         = "should be in hiragana format"
	PasswordMessage         = "should be in password format"
	UniqueMessage           = "must be unique"
	LessThanMessage         = "must be at less than %s"
	LessThanEuqalMessage    = "must be at less than or equal to %s"
	GreaterThanMessage      = "must be at greater than %s"
	GreaterThanEqualMessage = "must be at greater than or equal to %s"
	OneOfMessage            = "must be one of %s"
)

バリデーションメッセージ

View Source
const (
	CustomUniqueMessage        = "already exists"
	UnableConvertBase64Message = "cannot be converted to base64"
)

カスタムバリデーションメッセージ

Variables

This section is empty.

Functions

func ToDBError

func ToDBError(err error) error

func ToFirebaseError

func ToFirebaseError(err error) error

Types

type CustomError

type CustomError struct {
	ErrorCode        ErrorCode
	Value            error
	ValidationErrors []*ValidationError
}

CustomError - エラーコードを含めた構造体

func (CustomError) Code

func (ce CustomError) Code() ErrorCode

Code - エラーコードを返す

func (CustomError) Error

func (ce CustomError) Error() string

Error - エラー内容を返す

func (CustomError) Validations

func (ce CustomError) Validations() []*ValidationError

Validations - バリデーションエラーの詳細を返す

type ErrorCode

type ErrorCode uint

ErrorCode - システムエラーの種類

const (
	// ErrUnknown - 不明なエラー
	ErrUnknown ErrorCode = iota
	// ErrInvalidArgument - バリデーションエラー
	ErrInvalidArgument
	// ErrInvalidRequestValidation - バリデーションエラー (リクエスト)
	ErrInvalidRequestValidation
	// ErrInvalidDomainValidation - バリデーションエラー (ドメイン)
	ErrInvalidDomainValidation
	// ErrUnableConvertBase64 - Byte64型への変換エラー
	ErrUnableConvertBase64
	// ErrUnauthorized - 認証エラー
	ErrUnauthorized
	// ErrSessionExpired - セッションが有効期限切れ
	ErrSessionExpired
	// ErrForbidden - 権限エラー
	ErrForbidden
	// ErrPreconditionFailed - アクセス拒否
	ErrPreconditionFailed
	// ErrNotFound - 取得エラー
	ErrNotFound
	// ErrNotExistsInDatastore - データストアに対象のレコードが存在しない
	ErrNotExistsInDatastore
	// ErrNotExistsInStorage - ストレージに対象のファイルが存在しない
	ErrNotExistsInStorage
	// ErrConflict - 既存レコード,ファイルとの競合
	ErrConflict
	// ErrServiceUnavailable - サービスが利用不可(接続不可)
	ErrServiceUnavailable
	// ErrNotImplemented - サービスが利用不可(未実装)
	ErrNotImplemented
	// ErrGatewayTimeout - 接続タイムアウト
	ErrGatewayTimeout
	// ErrInternal - 内部エラー
	ErrInternal
	// ErrInDatastore - データベースエラー
	ErrInDatastore
	// ErrInStorage - ストレージエラー
	ErrInStorage
)

func (ErrorCode) New

func (ec ErrorCode) New(err error, ves ...*ValidationError) error

New - 指定したErrorCodeを持つCustomErrorを返す

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError - バリデーションエラー用構造体

Jump to

Keyboard shortcuts

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