errs

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 11 Imported by: 0

README

サンプルリスト

このディレクトリには以下のサンプルがあります。

file example name note
error_basic.go error_basic error のハンドリングについてのサンプル
error_sentinel.go error_sentinel Goにおけるエラー処理イディオムの sentinel error check についてのサンプルです.
error_typeassertion.go error_typeassertion Goにおけるエラー処理イディオムの type assertion check についてのサンプルです.
error_wrap_unwrap.go error_wrap_unwrap Goにおけるエラー処理にてエラーを内包するやり方についてのサンプルです。
error_is_and_as.go error_is_and_as errors.Is(), errors.As() のサンプルです。
error_wrap_multiple_error.go error_wrap_multiple_error Go 1.20 で導入された %w を複数指定できるようになった機能のサンプルです。

Documentation

Overview

Package errs -- エラーについてのサンプルが配置されているパッケージです。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSentinel -- sentinel error check
	ErrSentinel = errors.New("example: sentinel error check")
)

Functions

func ErrorJoin added in v0.5.1

func ErrorJoin() error

ErrorJoin は、Go 1.20 で追加された errors.Join のサンプルです.

Go 1.20 で、errors.Join が追加され、複数のエラーを纏めて一つに することが標準ライブラリで出来るようになった.

REFERENCES

func ErrorJoinErrorsAs added in v0.5.1

func ErrorJoinErrorsAs() error

ErrorJoinErrorsAs は、Go1.20から追加された errors.Join() と errors.As() の関係性についてのサンプルです.

func ErrorJoinFmtErrorf added in v0.5.1

func ErrorJoinFmtErrorf() error

ErrorJoinFmtErrorf は、Go1.20から追加された複数エラーを纏める機能が追加されたfmt.Errorfのサンプルです.

func IsAndAs added in v0.5.0

func IsAndAs() error

IsAndAs -- errors.Is(), errors.As() のサンプルです。

REFERENCES

func NewRegister

func NewRegister() mapping.Register

NewRegister -- このパッケージ用のサンプルを登録する mapping.Register を生成します。

func Sentinel

func Sentinel() error

Sentinel は、Goにおけるエラー処理イディオムの sentinel error check についてのサンプルです. REFERENCES::

func TypeAssertion

func TypeAssertion() error

TypeAssertion は、Goにおけるエラー処理イディオムの type assertion check についてのサンプルです. REFERENCES::

func WrapAndUnwrap

func WrapAndUnwrap() error

WrapAndUnwrap は、Goにおけるエラー処理にてエラーを内包するやり方についてのサンプルです。 REFERENCES::

func WrapMultipleError added in v0.5.11

func WrapMultipleError() error

WrapMultipleError は、Go 1.20 で導入された %w を複数指定できるようになった機能のサンプルです。

REFERENCES

Types

type MyError1 added in v0.5.1

type MyError1 struct {
	Message string
	Code    int
}

func (MyError1) Error added in v0.5.1

func (me MyError1) Error() string

type MyError2 added in v0.5.1

type MyError2 struct {
	Message string
	Code    int
}

func (MyError2) Error added in v0.5.1

func (me MyError2) Error() string

type MyError3 added in v0.5.1

type MyError3 struct {
	Message string
	Code    int
}

func (MyError3) Error added in v0.5.1

func (me MyError3) Error() string

type TypeAssertionError

type TypeAssertionError struct{}

TypeAssertionError -- type assertion check

func (*TypeAssertionError) Error

func (t *TypeAssertionError) Error() string

type WrapError

type WrapError struct {
	InnerError error
}

WrapError -- wrap error object

func (*WrapError) Error

func (w *WrapError) Error() string

func (*WrapError) Unwrap

func (w *WrapError) Unwrap() error

Unwrap -- 内包しているエラーを返します。

Jump to

Keyboard shortcuts

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