forked from TrueCloudLab/rclone
Make sure wrapped retry/fatal errors are never nil to avoid panic
This commit is contained in:
parent
ec0916c59d
commit
8083804575
1 changed files with 6 additions and 0 deletions
|
@ -58,6 +58,9 @@ var _ Retrier = wrappedRetryError{(error)(nil)}
|
||||||
|
|
||||||
// RetryError makes an error which indicates it would like to be retried
|
// RetryError makes an error which indicates it would like to be retried
|
||||||
func RetryError(err error) error {
|
func RetryError(err error) error {
|
||||||
|
if err == nil {
|
||||||
|
err = errors.New("needs retry")
|
||||||
|
}
|
||||||
return wrappedRetryError{err}
|
return wrappedRetryError{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +103,9 @@ var _ Fataler = wrappedFatalError{(error)(nil)}
|
||||||
// FatalError makes an error which indicates it is a fatal error and
|
// FatalError makes an error which indicates it is a fatal error and
|
||||||
// the sync should stop.
|
// the sync should stop.
|
||||||
func FatalError(err error) error {
|
func FatalError(err error) error {
|
||||||
|
if err == nil {
|
||||||
|
err = errors.New("fatal error")
|
||||||
|
}
|
||||||
return wrappedFatalError{err}
|
return wrappedFatalError{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue