applyError creates a new *ApplyError wrapping err or augments the information in err with args if it is already an *ApplyError. Returns nil if err is nil.
(err error, args ...interface{})
| 62 | // applyError creates a new *ApplyError wrapping err or augments the information |
| 63 | // in err with args if it is already an *ApplyError. Returns nil if err is nil. |
| 64 | func applyError(err error, args ...interface{}) error { |
| 65 | if err == nil { |
| 66 | return nil |
| 67 | } |
| 68 | |
| 69 | e, ok := err.(*ApplyError) |
| 70 | if !ok { |
| 71 | if err == io.EOF { |
| 72 | err = io.ErrUnexpectedEOF |
| 73 | } |
| 74 | e = &ApplyError{err: err} |
| 75 | } |
| 76 | for _, arg := range args { |
| 77 | switch v := arg.(type) { |
| 78 | case lineNum: |
| 79 | e.Line = int64(v) + 1 |
| 80 | case fragNum: |
| 81 | e.Fragment = int(v) + 1 |
| 82 | case fragLineNum: |
| 83 | e.FragmentLine = int(v) + 1 |
| 84 | } |
| 85 | } |
| 86 | return e |
| 87 | } |
| 88 | |
| 89 | var ( |
| 90 | errApplyInProgress = errors.New("gitdiff: incompatible apply in progress") |
no outgoing calls
no test coverage detected