[cs13001] Throwing outside functions

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Dec 10 19:46:50 EST 2012


> 
> I was supposed to email you regarding the syntax for the function
> head/prototype for throwing an exception outside a function.
> 

Well, better answering late than never. By default a function may
throw any exception which will be handled outside this
function. However, the list of exceptions to be thrown by a function
may be limited with "throw" qualifier in the function head/prototype:


  returnVal functionName(parameterList) throw (exceptionType1, exceptionType2);

If this qualifier is stated, and the function throws an exception of
the type that is not listed in its head/prototype than a special
function unexpected() is invoked. By default, this function terminates
the program. Empty list of thrown exceptions:

  returnVal functionName(parameterList) throw ();

Means that the function is not expected to throw any.

Thanks,
-- 
Mikhail


More information about the cs13001 mailing list