summaryrefslogtreecommitdiff
path: root/internal/commands/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/commands/util.go')
-rw-r--r--internal/commands/util.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/commands/util.go b/internal/commands/util.go
new file mode 100644
index 000000000..26c308648
--- /dev/null
+++ b/internal/commands/util.go
@@ -0,0 +1,18 @@
+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)
+ }
+}