We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 138dea0 commit bcfcda7Copy full SHA for bcfcda7
errors/gerror/gerror_z_example_test.go
@@ -82,3 +82,25 @@ func ExampleIs() {
82
// true
83
// false
84
}
85
+
86
+func ExampleCode() {
87
+ err1 := gerror.NewCode(gcode.CodeInternalError, "permission denied")
88
+ err2 := gerror.Wrap(err1, "operation failed")
89
+ fmt.Println(gerror.Code(err1))
90
+ fmt.Println(gerror.Code(err2))
91
92
+ // Output:
93
+ // 50:Internal Error
94
95
+}
96
97
+func ExampleHasCode() {
98
99
100
+ fmt.Println(gerror.HasCode(err1, gcode.CodeOK))
101
+ fmt.Println(gerror.HasCode(err2, gcode.CodeInternalError))
102
103
104
+ // false
105
+ // true
106
0 commit comments