← nimrepo

Exceptions

581bb068479c2622984cb4b7fcde450f1855a697 · ovidiucs · Feb 1, 2019 12:00

+8 · 1 file changed

  • raisingExceptions.nim +8 −0
diff --git a/raisingExceptions.nim b/raisingExceptions.nim
new file mode 100644
index 0000000..76ec04b
--- /dev/null
+++ b/raisingExceptions.nim
@@ -0,0 +1,8 @@
+import strformat
+type
+    MyError = object of Exception
+
+try:
+    raise newException(MyError, "details about what went wrong")
+except MyError:
+    echo fmt"[Error] {getCurrentException().name}: {getCurrentException().msg}"
\ No newline at end of file