| Conditions | 5 |
| Total Lines | 27 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.0187 |
| Changes | 0 | ||
| 1 | /* |
||
| 28 | func addTrace(err error, format string, args ...interface{}) error { |
||
| 29 | |||
| 30 | 1 | if err == nil { |
|
| 31 | return nil |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | message := format |
|
| 35 | 1 | if args != nil { |
|
| 36 | 1 | message = fmt.Sprintf(format, args...) |
|
| 37 | } |
||
| 38 | 1 | pc, file, line, _ := runtime.Caller(2) |
|
| 39 | 1 | info := StackDetails{ |
|
| 40 | File: file, |
||
| 41 | Line: line, |
||
| 42 | FuncName: runtime.FuncForPC(pc).Name(), |
||
| 43 | Message: message, |
||
| 44 | } |
||
| 45 | |||
| 46 | 1 | switch err.(type) { |
|
| 47 | case EnhancedError: |
||
| 48 | 1 | err.(*enhancedError).stack = append(err.(*enhancedError).stack, info) |
|
| 49 | 1 | return err |
|
| 50 | |||
| 51 | default: |
||
| 52 | 1 | return &enhancedError{ |
|
| 53 | err: err, |
||
| 54 | stack: append(make([]StackDetails, 0), info), |
||
| 55 | } |
||
| 58 |