September 2013
Intermediate to advanced
548 pages
12h 25m
English
If you’re familiar with Java, then you’ll have no difficulties understanding the try…catch expression. Java can trap an exception with the following syntax:
| | try { |
| | block |
| | } catch (exception type identifier) { |
| | block |
| | } catch (exception type identifier) { |
| | block |
| | } ... |
| | finally { |
| | block |
| | } |
Erlang has a remarkably similar construct, which looks like this:
| | try FuncOrExpressionSeq of |
| | Pattern1 [when Guard1] -> Expressions1; |
| | Pattern2 [when Guard2] -> Expressions2; |
| | ... |
| | catch |
| | ExceptionType1: ExPattern1 [when ExGuard1] -> ExExpressions1; |
| | ExceptionType2: ExPattern2 [when ExGuard2] -> ExExpressions2; |
| | ... |
| | after |
| | AfterExpressions |
| | end |
Remember, ...
Read now
Unlock full access