Skip to content

Commit ecd1932

Browse files
committed
Source returns the first line of the client application
1 parent b62ab86 commit ecd1932

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

dev.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Application.put_env(:error_tracker, ErrorTrackerDevWeb.Endpoint,
4141
]
4242
)
4343

44+
# Setup up the ErrorTracker configuration
4445
Application.put_env(:error_tracker, :repo, ErrorTrackerDev.Repo)
46+
Application.put_env(:error_tracker, :application, :error_tracker_dev)
4547

4648
defmodule ErrorTrackerDevWeb.PageController do
4749
import Plug.Conn

lib/error_tracker/models/stacktrace.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ defmodule ErrorTracker.Stacktrace do
3838
Ecto.Changeset.cast(line, params, ~w[application module function arity file line]a)
3939
end
4040

41+
@doc """
42+
Source of the error stack trace.
43+
44+
The first line matching the client application. If no line belongs to the current
45+
application, just the first line.
46+
"""
4147
def source(stack = %__MODULE__{}) do
42-
List.first(stack.lines)
48+
client_app = Application.fetch_env!(:error_tracker, :application)
49+
50+
Enum.find(stack.lines, &(&1.application == client_app)) || List.first(stack.lines)
4351
end
4452
end
4553

0 commit comments

Comments
 (0)