summaryrefslogtreecommitdiffstats
path: root/wat/utils.go
diff options
context:
space:
mode:
authorPratyush Desai2024-10-12 20:05:22 +0200
committerPratyush Desai2024-10-12 20:05:22 +0200
commit67ef6fec1b6b4ca6b99701109b15f60a853dc5a2 (patch)
treee4a9814487f76716c063511ff5379c3647a05463 /wat/utils.go
parent91b0e21b7ac29d11d7c6774c92c99f4640a1a8d1 (diff)
parent930839ab58a60a5e3026de6f8a659fdcd8c25173 (diff)
downloadwatbot-master.tar.gz
watbot-master.tar.bz2
watbot-master.zip
Merge pull request 'Prevent dice overflow' (#27) from overflow into masterHEADmaster
Reviewed-on: https://git.com.de/LibertaCasa/watbot/pulls/27
Diffstat (limited to 'wat/utils.go')
-rw-r--r--wat/utils.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/wat/utils.go b/wat/utils.go
new file mode 100644
index 0000000..331f7ad
--- /dev/null
+++ b/wat/utils.go
@@ -0,0 +1,22 @@
+package wat
+
+import (
+ "fmt"
+ "runtime"
+)
+
+func handleError(err error) string {
+ if err != nil {
+ pc, _, _, ok := runtime.Caller(1)
+ details := runtime.FuncForPC(pc)
+ var cFun string
+ if ok && details != nil {
+ cFun = details.Name()
+ } else {
+ cFun = "???"
+ }
+ fmt.Printf("caught error in %s: %v\n", cFun, err)
+ return "u wat"
+ }
+ return ""
+}