From b3f8c74058420834b689848c613223b1d41d7a99 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Tue, 27 Oct 2020 02:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erlang/elangtrycatch说明.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 erlang/elangtrycatch说明.md diff --git a/erlang/elangtrycatch说明.md b/erlang/elangtrycatch说明.md new file mode 100644 index 0000000..f25055d --- /dev/null +++ b/erlang/elangtrycatch说明.md @@ -0,0 +1,19 @@ +# catch + catch Expr + 除非评估期间发生异常,否则返回Expr的值。在这种情况下,将捕获异常。 + 对于类错误(即运行时错误)的异常,将返回 {'EXIT',{Reason,Stack}}。 + 对于类exit的异常,即返回称为exit(Term), {'EXIT',Term}的代码。 + 对于类throw的异常(即称为throw(Term)的代码), 将返回Term。 + 原因取决于发生的错误的类型, 堆栈是最近的函数调用的堆栈, + + catch error会返回堆栈 性能低 + catch exit/throw 不会返回堆栈 但是性能比普通函数调用低几倍 + +# try catch + 匹配格式为Clcass:Reason:Strace 并且 使用了Strace的时候 会返回堆栈 性能 跟 catch error 差不多 + 如果不匹配strace或者匹配了不使用Strace, try catch exit error throw 性能跟catch exit/throw差不多, 无太大差别 + + + + + \ No newline at end of file