JADE Environment Development Ideas

Support for a Try/Catch style exception handling

Many development environments support a try/catch exception handling style, typically:

try {
// do stuff
}
catch (exceptionObject) {
// handle exceptions
}

Statements in the try block are executed and, if there is an exception of a type compatible with the declaration of the exceptionObject in the catch block, that block is executed to handle the exception.

Multiple catch blocks for the one try block can also be supported.

The benefits are

1) code is easier to read and understand,
2) exception handling code is alongside the code being executed
3) it is a more standard style of exception handling that developers new to Jade will be more familiar with and pick up very easily.

Obviously it would need to work alongside the existing Exception Handling code.
  • Guest
  • May 1 2019
  • Future consideration
HistoricalComments
Brian Johnstone 18/11/2017 11:22:24 AM
I've always found that having try/catch means that you're polluting the "normal" code in order to put in the exception handling code, which to me actually makes the "normal" code harder to read not easier. Not to mention that for some exceptions, resuming at the next line of code is cleaner than having the same code repeated in an exception block and in the "normal" route, to handle those situations where you want to carry on with the same code for some exception types. Having said that, being able to use either means could still be a useful enhancement for those coming to Jade from other languages.
  • Attach files
  • +14