19 lines
314 B
Go
19 lines
314 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func recoverErr(i any) 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)
|
|
}
|
|
}
|