aboutsummaryrefslogtreecommitdiff
path: root/core/error.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2023-10-24 07:20:10 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2023-10-24 07:20:29 +0200
commit18476c6cba2d5d2bb3ecf3ad136dacbf41d0360e (patch)
treea7a958ff7a4bf14ed7f7ee3ffd9c84b7592facbd /core/error.go
feat: Extract from other repo
Diffstat (limited to 'core/error.go')
-rw-r--r--core/error.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/error.go b/core/error.go
new file mode 100644
index 0000000..7b1871a
--- /dev/null
+++ b/core/error.go
@@ -0,0 +1,16 @@
+package core
+
+import "fmt"
+
+func Wrap(err error, msg string) error {
+ return fmt.Errorf("%s: %w", msg, err)
+}
+
+func Expect(err error, msg string) {
+ if err != nil {
+ if msg != "" {
+ err = Wrap(err, msg)
+ }
+ panic(err)
+ }
+}