redactPathError checks if the error is actually a os.PathError, and if yes returns a redactedError with the path removed.
(err error)
| 3473 | // redactPathError checks if the error is actually a os.PathError, and if yes |
| 3474 | // returns a redactedError with the path removed. |
| 3475 | func redactPathError(err error) (error, bool) { |
| 3476 | var perr *os.PathError |
| 3477 | if !errors.As(err, &perr) { |
| 3478 | return nil, false |
| 3479 | } |
| 3480 | return &redactedError{ |
| 3481 | error: err, |
| 3482 | redacted: fmt.Errorf("%v: %w", perr.Op, perr.Err), |
| 3483 | }, true |
| 3484 | } |
| 3485 | |
| 3486 | type redactedError struct { |
| 3487 | error |