From 01e8b35e7fc11874b69e8f90149ced25a46f3584 Mon Sep 17 00:00:00 2001 From: DenChenn Date: Wed, 6 Sep 2023 16:59:36 +0800 Subject: [PATCH] doc: type assertion --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 9441802..6095c64 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,13 @@ if errors.Is(err, &pgx.ErrNoRows) { return &alayer.Err1.Wrap(err) } ``` + +## Type assertion +All generated errors implement `blunder.OrdinaryError` interface, which contains static methods. + +```go +ordinaryError, ok := err.(blunder.OrdinaryError) +if ok { + fmt.Println(ordinaryError.GetId()) +} +```