19 lines
322 B
Go
19 lines
322 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func recoverErr(i interface{}) error {
|
|
switch v := i.(type) {
|
|
case nil:
|
|
return nil
|
|
case string:
|
|
return fmt.Errorf("recovered panic: %s", v)
|
|
case error:
|
|
return fmt.Errorf("recovered panic: %w", v)
|
|
default:
|
|
return fmt.Errorf("recovered panic with unknown type: %v", v)
|
|
}
|
|
}
|