19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ead(fileName) =<br />

try<br />

readFile(fileName)<br />

catch e<br />

IOException ⇒throw Error(“This code can’t handle IOExceptions”, e)<br />

end<br />

where the message and chain fields of Error are set to “This code can’t handle IOExceptions” and<br />

IOException respectively.<br />

By default, a forbid clause in a try expression throws a new ForbiddenException by chaining the exception<br />

thrown by the try block in the try expression that is a subtype of the exception type listed in the forbid clause.<br />

For example, the following read function:<br />

read(fileName) =<br />

try<br />

readFile(fileName)<br />

forbid IOException<br />

end<br />

is equivalent to:<br />

read(fileName) =<br />

try<br />

readFile(fileName)<br />

catch e<br />

IOException ⇒throw ForbiddenException(e)<br />

end<br />

where the chain of ForbiddenException is set to IOException.<br />

120

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!