Skip to content

Commit fc5709d

Browse files
committed
Call Repo dynamically
1 parent 9b5a40d commit fc5709d

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

lib/error_tracker.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
defmodule ErrorTracker do
2-
alias ErrorTracker.Repo
3-
42
def report(exception, stacktrace, context \\ %{}) do
53
{:ok, stacktrace} = ErrorTracker.Stacktrace.new(stacktrace)
64
{:ok, error} = ErrorTracker.Error.new(exception, stacktrace)
75

86
error =
9-
Repo.insert!(error,
7+
repo().insert!(error,
108
on_conflict: [set: [status: :unresolved]],
119
conflict_target: :fingerprint
1210
)
1311

1412
error
1513
|> Ecto.build_assoc(:occurrences, stacktrace: stacktrace, context: context)
16-
|> Repo.insert!()
14+
|> repo().insert!()
1715
end
1816

19-
def raise do
20-
raise "PROBANDO PROBANDO"
21-
rescue
22-
e -> report(e, __STACKTRACE__)
17+
def repo do
18+
Application.fetch_env!(:error_tracker, :repo)
2319
end
2420
end

0 commit comments

Comments
 (0)