File tree 2 files changed +10
-7
lines changed
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,17 @@ type (
40
40
//
41
41
// error sending response: UDP not listening
42
42
func (o * Result ) Logf (a ... any ) * Result {
43
- if o .Err == nil || len ( a ) == 0 {
43
+ if o .Err == nil {
44
44
return o
45
45
}
46
- f , isFormat := a [0 ].(string )
47
- if isFormat {
48
- s := fmt .Sprintf (f + ": %v" , append (a [1 :], o .Err )... )
49
- _ = handler .LogOutput (2 , s )
46
+ s := o .Err .Error ()
47
+ if len (a ) != 0 {
48
+ f , isFormat := a [0 ].(string )
49
+ if isFormat {
50
+ s = fmt .Sprintf (f + ": %v" , append (a [1 :], o .Err )... )
51
+ }
50
52
}
53
+ _ = handler .LogOutput (2 , s )
51
54
return o
52
55
}
53
56
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ func ExampleResult2_Logf() {
21
21
err2 .SetLogTracer (os .Stdout )
22
22
23
23
countSomething := func (s1 , s2 string ) (int , int ) {
24
- r := try .Out2 (convTwoStr (s1 , s2 )).Logf ("not number" ).Def2 (10 , 10 )
24
+ r := try .Out2 (convTwoStr (s1 , s2 )).Logf ().Def2 (10 , 10 )
25
25
v1 , v2 := r .Val1 , r .Val2
26
26
return v1 + v2 , v2
27
27
}
28
28
_ , _ = countSomething ("1" , "2" )
29
29
num1 , num2 := countSomething ("WRONG" , "2" )
30
30
fmt .Printf ("results: %d, %d" , num1 , num2 )
31
31
err2 .SetLogTracer (nil )
32
- // Output: not number: testing run example: strconv.Atoi: parsing "WRONG": invalid syntax
32
+ // Output: testing run example: strconv.Atoi: parsing "WRONG": invalid syntax
33
33
// results: 20, 10
34
34
}
You can’t perform that action at this time.
0 commit comments