Always pass stracktrace when necessary
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user