Skip to content

Commit 0c9778a

Browse files
committed
try_catch by kapu1178
1 parent 6f53520 commit 0c9778a

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
- [HTTP]()
3939
- [FFI]()
4040
- [Error Handling]()
41-
- [Try/Catch]()
41+
- [Try/Catch](./errors/try_catch.md)
4242
- [Meta](./meta.md)
4343
- [Language Server](./meta/lang_server.md)
4444
- [DMDoc](./meta/dmdoc.md)

src/errors/try_catch.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Try / Catch
2+
3+
You can prevent exceptions ("runtimes") from terminating a proc utilizing a try/catch block. If an exception occurs in any of the code within the "try" block, or any functions called inside of it, it will "catch" the exception in the "catch" block.
4+
5+
If an exception occurs within a try/catch block, it will unwind the entire callstack back to the try block.
6+
7+
```
8+
try
9+
var/foo = ""
10+
foo += 1
11+
12+
catch(exception/e)
13+
world.log << "Caught an exception! [e.name]"
14+
```

0 commit comments

Comments
 (0)