Always pass stracktrace when necessary

This commit is contained in:
sabiwara
2023-08-23 12:06:07 +02:00
committed by José Valim
parent 36c3f7594d
commit 84c8d23710
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ normalize_rescue(Meta, Var, Pattern, Expr, ErlangAliases) ->
dynamic_normalize(Meta, Var, ?REQUIRES_STACKTRACE);
false ->
case lists:splitwith(fun is_normalized_with_stacktrace/1, ErlangAliases) of
case lists:partition(fun is_normalized_with_stacktrace/1, ErlangAliases) of
{[], _} -> [];
{_, []} -> {'__STACKTRACE__', Meta, nil};
{Some, _} -> dynamic_normalize(Meta, Var, Some)
@@ -224,6 +224,17 @@ defmodule Kernel.RaiseTest do
assert result == "an exception"
end
test "named function clause (stacktrace) or runtime (no stacktrace) error" do
result =
try do
Access.get("foo", 0)
rescue
x in [FunctionClauseError, CaseClauseError] -> Exception.message(x)
end
assert result == "no function clause matching in Access.get/3"
end
test "with higher precedence than catch" do
result =
try do