July 20th Monday (七月 二十日 月曜日)
来源:互联网 发布:node.js react区别 编辑:程序博客网 时间:2024/05/11 15:02
Try
try Exprs
catch
[Class1:]ExceptionPattern1 [when ExceptionGuardSeq1] ->
ExceptionBody1;
[ClassN:]ExceptionPatternN [when ExceptionGuardSeqN] ->
ExceptionBodyN
end
This is an enhancement of catch that appeared in Erlang 5.4/OTP-R10B. It gives the possibility do distinguish between different exception classes, and to choose to handle only the desired ones, passing the others on to an enclosing try or catch or to default error handling.
Note that although the keyword catch is used in the try expression, there is not a catch expression within the try expression.
Returns the value of Exprs (a sequence of expressions Expr1, ..., ExprN) unless an exception occurs during the evaluation. In that case the exception is caught and the patterns ExceptionPattern with the right exception class Class are sequentially matched against the caught exception. An omitted Class is shorthand for throw. If a match succeeds and the optional guard sequence ExceptionGuardSeq is true, the corresponding ExceptionBody is evaluated to become the return value.
If an exception occurs during evaluation of Exprs but there is no matching ExceptionPattern of the right Class with a true guard sequence, the exception is passed on as if Exprs had not been enclosed in a try expression.
If an exception occurs during evaluation of ExceptionBody it is not caught.
The try expression can have an of section:
try Exprs of
Pattern1 [when GuardSeq1] ->
Body1;
...;
PatternN [when GuardSeqN] ->
BodyN
catch
[Class1:]ExceptionPattern1 [when ExceptionGuardSeq1] ->
ExceptionBody1;
...;
[ClassN:]ExceptionPatternN [when ExceptionGuardSeqN] ->
ExceptionBodyN
end
If the evaluation of Exprs succeeds without an exception, the patterns Pattern are sequentially matched against the result in the same way as for a case expression, except that if the matching fails, a try_clause run-time error will occur.
An exception occurring during the evaluation of Body is not caught.
The try expression can also be augmented with an after section, intended to be used for cleanup with side effects:
try Exprs of
Pattern1 [when GuardSeq1] ->
Body1;
...;
PatternN [when GuardSeqN] ->
BodyN
catch
[Class1:]ExceptionPattern1 [when ExceptionGuardSeq1] ->
ExceptionBody1;
...;
[ClassN:]ExceptionPatternN [when ExceptionGuardSeqN] ->
ExceptionBodyN
after
AfterBody
end
AfterBody is evaluated after either Body or ExceptionBody no matter which one. The evaluated value of AfterBody is lost; the return value of the try expression is the same with an after section as without.
Even if an exception occurs during evaluation of Body or ExceptionBody, AfterBody is evaluated. In this case the exception is passed on after AfterBody has been evaluated, so the exception from the try expression is the same with an after section as without.
If an exception occurs during evaluation of AfterBody itself it is not caught, so if AfterBody is evaluated after an exception in Exprs, Body or ExceptionBody, that exception is lost and masked by the exception in AfterBody.
The of, catch and after sections are all optional, as long as there is at least a catch or an after section, so the following are valid try expressions:
try Exprs of
Pattern when GuardSeq ->
Body
after
AfterBody
end
try Exprs
catch
ExpressionPattern ->
ExpressionBody
after
AfterBody
end
try Exprs after AfterBody end
- July 20th Monday (七月 二十日 月曜日)
- July 9th Monday (七月 九日 月曜日)
- July 16th Monday (七月 十六日 月曜日)
- July 6th Monday (七月 六日 月曜日)
- July 2th Monday (七月 二日 月曜日)
- July 23th Monday (七月 二十三日 月曜日)
- July 30th Monday (七月 三十日 月曜日)
- 2008 July 7th Monday (七月 七日 月曜日)
- 2008 July 14th Monday (七月 十四日 月曜日)
- 2008 July 21th Monday (七月 二十一日 月曜日)
- 2008 July 28th Monday (七月 二十八日 月曜日)
- July 13th Monday (七月 十一日 月曜日)
- July 27th Monday (七月 二十七日 月曜日)
- July 17th Monday (七月 十七日 火曜日)
- April 20th Monday (四月 二十日 月曜日)
- July 6th Friday (七月 六日 金曜日)
- July 12th Thursday (七月 十二日 木曜日)
- July 13th Friday (七月 十三日 金曜日)
- July 15th Wednesday (七月 十五日 水曜日)
- Ant初体验一
- July 16th Thursday (七月 十六日 木曜日)
- July 17th Friday (七月 十七日 金曜日)
- web开发常见问题和解决方法
- July 20th Monday (七月 二十日 月曜日)
- July 21th Tuesday (七月 二十一日 火曜日)
- July 22th Wednesday (七月 二十二日 水曜日)
- 电脑高手常用的按钮
- ora-01830错误:日期格式图片在转换整个输入字符串之前结束
- Detection of SQL Injection and Cross-site Scripting Attacks
- July 23th Thursday (七月 二十三日 木曜日)
- July 24th Friday (七月 二十四日 金曜日)
- July 27th Monday (七月 二十七日 月曜日)