diff --git a/lib/tower_rollbar/rollbar/item.ex b/lib/tower_rollbar/rollbar/item.ex index 5719cdd..cd909ff 100644 --- a/lib/tower_rollbar/rollbar/item.ex +++ b/lib/tower_rollbar/rollbar/item.ex @@ -98,9 +98,25 @@ defmodule TowerRollbar.Rollbar.Item do } end - defp frames(_stacktrace) do - # TODO: implement - [] + defp frames(stacktrace) do + stacktrace + |> Enum.map(fn {_m, _f, _a, location} -> + frame = %{} + + frame = + if location[:file] do + Map.put(frame, "filename", to_string(location[:file])) + else + frame + end + + if location[:line] do + Map.put(frame, "lineno", location[:line]) + else + frame + end + end) + |> Enum.reverse() end defp environment do diff --git a/test/tower_rollbar/rollbar/item_test.exs b/test/tower_rollbar/rollbar/item_test.exs index 6842661..f8fba9f 100644 --- a/test/tower_rollbar/rollbar/item_test.exs +++ b/test/tower_rollbar/rollbar/item_test.exs @@ -22,7 +22,24 @@ defmodule TowerRollbar.Rollbar.ItemTest do "level" => "error", "body" => %{ "trace" => %{ - "frames" => [], + "frames" => [ + %{ + "filename" => "lib/ex_unit/runner.ex", + "lineno" => _ + }, + %{ + "filename" => "timer.erl", + "lineno" => _ + }, + %{ + "filename" => "lib/ex_unit/runner.ex", + "lineno" => _ + }, + %{ + "filename" => "test/tower_rollbar/rollbar/item_test.exs", + "lineno" => 12 + } + ], "exception" => %{ "class" => "RuntimeError", "message" => "a test"