diff --git a/lib/tower_rollbar/rollbar/item.ex b/lib/tower_rollbar/rollbar/item.ex index dd19059..22bacd0 100644 --- a/lib/tower_rollbar/rollbar/item.ex +++ b/lib/tower_rollbar/rollbar/item.ex @@ -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))) @@ -42,7 +35,7 @@ defmodule TowerRollbar.Rollbar.Item do "frames" => frames(stacktrace), "exception" => %{ "class" => class, - "message" => reason + "message" => string_or_inspect(reason) } } } @@ -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 diff --git a/test/tower_rollbar_test.exs b/test/tower_rollbar_test.exs index e53043e..b95cae0 100644 --- a/test/tower_rollbar_test.exs +++ b/test/tower_rollbar_test.exs @@ -127,7 +127,7 @@ defmodule TowerRollbarTest do "trace" => %{ "exception" => %{ "class" => "(exit)", - "message" => "abnormal" + "message" => ":abnormal" }, "frames" => frames } @@ -301,7 +301,7 @@ defmodule TowerRollbarTest do "trace" => %{ "exception" => %{ "class" => "(exit)", - "message" => "abnormal" + "message" => ":abnormal" }, # Plug.Cowboy doesn't provide stacktrace for exits "frames" => []