-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
31 lines (24 loc) · 599 Bytes
/
Copy pathexample_test.go
File metadata and controls
31 lines (24 loc) · 599 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package exception_test
import (
"errors"
"fmt"
"github.com/Prastiwar/Go-flow/exception"
)
func ExampleAggregatedError() {
aggErr := exception.Aggregate(
errors.New("'' is not valid value for title"),
errors.New("title is required"),
)
err := fmt.Errorf("(%v) validation errors: %w", len(aggErr), aggErr)
fmt.Println(err)
// Output:
// (2) validation errors: ["'' is not valid value for title", "title is required"]
}
func ExampleHandlePanicError() {
defer exception.HandlePanicError(func(err error) {
fmt.Println(err)
})
panic("string error")
// Output:
// string error
}