File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -81,3 +81,33 @@ func Log(err error) error {
81
81
_ = handler .LogOutput (lvl , err .Error ())
82
82
return err
83
83
}
84
+
85
+ // StderrNoReset is a built-in helper to use with Handle and Catch. It prints
86
+ // the error to stderr. If you need to reset err value use Stderr instead.
87
+ //
88
+ // You can use it like this:
89
+ //
90
+ // func myFunction() {
91
+ // defer err2.Handle(err2.Noop, err2.StderrNoReset)
92
+ func StderrNoReset (err error ) error {
93
+ if err == nil {
94
+ return nil
95
+ }
96
+ fmt .Fprintln (os .Stderr , err .Error ())
97
+ return nil
98
+ }
99
+
100
+ // StdoutNoReset is a built-in helper to use with Handle and Catch. It prints
101
+ // the error to stdout.
102
+ //
103
+ // You can use it like this:
104
+ //
105
+ // func main() {
106
+ // defer err2.Catch(err2.StdoutNoReset)
107
+ func StdoutNoReset (err error ) error {
108
+ if err == nil {
109
+ return nil
110
+ }
111
+ fmt .Fprintln (os .Stdout , err .Error ())
112
+ return nil
113
+ }
You can’t perform that action at this time.
0 commit comments