Skip to content

Commit

Permalink
Always pass stracktrace when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara authored and josevalim committed Aug 23, 2023
1 parent 36c3f75 commit 84c8d23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elixir/src/elixir_erl_try.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions lib/elixir/test/elixir/kernel/raise_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 84c8d23

Please sign in to comment.