diff --git a/devNotes/exceptions.md b/devNotes/exceptions.md index 0abe7704403204ffbd1573fd2846b32f14720a2b..f7a66be9a1cdca70514a7beb9699ab7f9e93767e 100644 --- a/devNotes/exceptions.md +++ b/devNotes/exceptions.md @@ -2,10 +2,10 @@ With the movement away from passages as .tw files error handling is getting more important, especially proper cleanup. -Good example is #2654, the end week animation did not stop because `App.EndWeek.slaveAssignmentReport()` failed, which +Good example is [this issue](https://gitgud.io/pregmodfan/fc-pregmod/-/issues/2654), the end week animation did not stop because `App.EndWeek.slaveAssignmentReport()` failed, which meant that the endweek animation stop call wasn't executed. -### Finally +## Finally Example of the proper way to handle code that cleans up something and should therefore always be executed: @@ -22,7 +22,7 @@ try { Do note that this will still propagate the error up, it will just execute `cleanup code` first. If you want to handle the error use `catch` -### Catch +## Catch If needed a catch clause can be used as well, but it is usually advisable to only catch specific errors and only if you know they can be thrown and there is no easy way to prevent them. @@ -37,6 +37,6 @@ try { } ``` -### Reference +## Reference See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch