Menu

keywords-throws

Will Pittenger

In ASIL, all exceptions must be caught or declared. You declare that an exception might be thrown by a procedure with the throws keyword. It goes immediately after the procedure's identifier for all commands and complex statements. In the case of functions, it can go before or after the returns clause. With properties, place the clause just after the get and/or set keywords.

In each of the samples below, "/exceptionList/" should be a comma delimited list of types that implement Throwable. For what you can put where "/DeclarationSequence/" appears, see Declaration sequence.

For more on declaring these types of procedures, see [Commands], [Functions], and [Complex statements]. For more on declaring properties, see [Properties]. For more on exception handling, see [Exceptions]. For more on exception related keywords, see throw, try, catch, and finally.

Commands and complex statements

(\command\ | \statement\) identifier /DeclarationSequence/
   [\throws\ /exceptionList/]

Functions

\function\ identifier /DeclarationSequence/
  \returns\ Type
  [\throws\ /exceptionList/]

or

\function\ identifier /DeclarationSequence/
  [\throws\ /exceptionList/]
  \returns\ Type

Property accessors

A property where one accessor declares a given list of exceptions doesn't have to throw declare the sample list for the other accessor. The other accessor can declare a completely different set or none at all.

get accessors

\property\ Type identifier
  \get\
      [\throws\ exceptionList]

set accessors

\property\ Type identifier
  \set\
      [\throws\ exceptionList]

Related

Wiki: Appendices-Terms-Declaration sequence
Wiki: Commands
Wiki: Complex Statements
Wiki: Exceptions
Wiki: Functions
Wiki: Interfaces
Wiki: Keywords
Wiki: Properties
Wiki: keywords-catch
Wiki: keywords-finally
Wiki: keywords-returns
Wiki: keywords-throw
Wiki: keywords-try