diff --git a/lib/tower_rollbar/rollbar/item.ex b/lib/tower_rollbar/rollbar/item.ex index 5719cdd..676b82b 100644 --- a/lib/tower_rollbar/rollbar/item.ex +++ b/lib/tower_rollbar/rollbar/item.ex @@ -98,9 +98,27 @@ 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 = %{ + "method" => Exception.format_mfa(m, f, a) + } + + 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..1c4b9f8 100644 --- a/test/tower_rollbar/rollbar/item_test.exs +++ b/test/tower_rollbar/rollbar/item_test.exs @@ -22,7 +22,28 @@ defmodule TowerRollbar.Rollbar.ItemTest do "level" => "error", "body" => %{ "trace" => %{ - "frames" => [], + "frames" => [ + %{ + "method" => _, + "filename" => "lib/ex_unit/runner.ex", + "lineno" => _ + }, + %{ + "method" => _, + "filename" => "timer.erl", + "lineno" => _ + }, + %{ + "method" => _, + "filename" => "lib/ex_unit/runner.ex", + "lineno" => _ + }, + %{ + "method" => ~s(TowerRollbar.Rollbar.ItemTest."test from_exception"/1), + "filename" => "test/tower_rollbar/rollbar/item_test.exs", + "lineno" => 12 + } + ], "exception" => %{ "class" => "RuntimeError", "message" => "a test"