Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support tuple value in error message #43

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/tower_rollbar/rollbar/item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,9 @@ defmodule TowerRollbar.Rollbar.Item do
end

def from_event(%Tower.Event{kind: :message, level: level, reason: reason} = event) do
message =
if is_binary(reason) do
reason
else
inspect(reason)
end

%{
"message" => %{
"body" => message
"body" => string_or_inspect(reason)
}
}
|> item_from_body(Keyword.merge([level: level], options_from_event(event)))
Expand All @@ -42,7 +35,7 @@ defmodule TowerRollbar.Rollbar.Item do
"frames" => frames(stacktrace),
"exception" => %{
"class" => class,
"message" => reason
"message" => string_or_inspect(reason)
}
}
}
Expand Down Expand Up @@ -177,4 +170,7 @@ defmodule TowerRollbar.Rollbar.Item do
defp os do
"type: #{inspect(:os.type())} version: #{inspect(:os.version())}"
end

defp string_or_inspect(data) when is_binary(data), do: data
defp string_or_inspect(data), do: inspect(data)
end
4 changes: 2 additions & 2 deletions test/tower_rollbar_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

capture_log(fn ->
in_unlinked_process(fn ->
1 / 0

Check warning on line 60 in test/tower_rollbar_test.exs

View workflow job for this annotation

GitHub Actions / main (1.15, 25.3.2.15, plug_1_15)

the call to //2 will fail with ArithmeticError

Check warning on line 60 in test/tower_rollbar_test.exs

View workflow job for this annotation

GitHub Actions / main (1.15, 24.3.4.17, plug_1_14)

the call to //2 will fail with ArithmeticError

Check warning on line 60 in test/tower_rollbar_test.exs

View workflow job for this annotation

GitHub Actions / main (1.15, 25.3.2.15, plug_1_15)

the call to //2 will fail with ArithmeticError

Check warning on line 60 in test/tower_rollbar_test.exs

View workflow job for this annotation

GitHub Actions / main (1.15, 24.3.4.17, plug_1_14)

the call to //2 will fail with ArithmeticError
end)
end)
end)
Expand Down Expand Up @@ -127,7 +127,7 @@
"trace" => %{
"exception" => %{
"class" => "(exit)",
"message" => "abnormal"
"message" => ":abnormal"
},
"frames" => frames
}
Expand Down Expand Up @@ -301,7 +301,7 @@
"trace" => %{
"exception" => %{
"class" => "(exit)",
"message" => "abnormal"
"message" => ":abnormal"
},
# Plug.Cowboy doesn't provide stacktrace for exits
"frames" => []
Expand Down
Loading