Exception Declaration

Exception declaration is a way of letting the compiler and the programmer know, that a method can throw an exception in certain scenarios. It helps set clear expectations of the code behaviour and also warn the developer in case an possible exception is not caught.

Not all languages support this though. Some languages like Python and JavaScript are more lenient with the exceptions you throw. While some other languages will warn you (like ABAP) or even show an error (like Java) if you raise an exception which you have not declared.


Backlinks