Skip to content

Commit 84c8d23

Browse files
sabiwarajosevalim
authored andcommitted
Always pass stracktrace when necessary
1 parent 36c3f75 commit 84c8d23

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/elixir/src/elixir_erl_try.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ normalize_rescue(Meta, Var, Pattern, Expr, ErlangAliases) ->
5555
dynamic_normalize(Meta, Var, ?REQUIRES_STACKTRACE);
5656

5757
false ->
58-
case lists:splitwith(fun is_normalized_with_stacktrace/1, ErlangAliases) of
58+
case lists:partition(fun is_normalized_with_stacktrace/1, ErlangAliases) of
5959
{[], _} -> [];
6060
{_, []} -> {'__STACKTRACE__', Meta, nil};
6161
{Some, _} -> dynamic_normalize(Meta, Var, Some)

lib/elixir/test/elixir/kernel/raise_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ defmodule Kernel.RaiseTest do
224224
assert result == "an exception"
225225
end
226226

227+
test "named function clause (stacktrace) or runtime (no stacktrace) error" do
228+
result =
229+
try do
230+
Access.get("foo", 0)
231+
rescue
232+
x in [FunctionClauseError, CaseClauseError] -> Exception.message(x)
233+
end
234+
235+
assert result == "no function clause matching in Access.get/3"
236+
end
237+
227238
test "with higher precedence than catch" do
228239
result =
229240
try do

0 commit comments

Comments
 (0)