File tree Expand file tree Collapse file tree 4 files changed +13
-7
lines changed Expand file tree Collapse file tree 4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -55,4 +55,14 @@ defmodule ErrorTracker.Error do
55
55
|> Ecto.Changeset . put_change ( :last_occurrence_at , DateTime . utc_now ( ) )
56
56
|> Ecto.Changeset . apply_action ( :new )
57
57
end
58
+
59
+ @ doc """
60
+ Returns if the Error has information of the source or not.
61
+
62
+ Errors usually have information about in which line and function occurred, but
63
+ in some cases (like an Oban job ending with `{:error, any()}`) we cannot get
64
+ that information and no source is stored.
65
+ """
66
+ defp has_source_info? ( % Error { source_function: "-" , source_line: "-" } ) , do: false
67
+ defp has_source_info? ( % Error { } ) , do: true
58
68
end
Original file line number Diff line number Diff line change 69
69
< p class = "whitespace-nowrap text-ellipsis w-full overflow-hidden " >
70
70
(<%= sanitize_module ( error . kind ) %> ) <%= error . reason %>
71
71
</ p >
72
- < p :if = { error . source_function != "-" } class = "font-normal text-gray-400 " >
72
+ < p :if = { ErrorTracker.Error . has_source_info? ( error ) } class = "font-normal text-gray-400 " >
73
73
<%= sanitize_module ( error . source_function ) %>
74
- </ p >
75
- < p :if = { error . source_function != "-" } class = "font-normal text-gray-400 " >
74
+ < br />
76
75
<%= error . source_line %>
77
76
</ p >
78
77
</ td >
Original file line number Diff line number Diff line change @@ -121,7 +121,4 @@ defmodule ErrorTracker.Web.Live.Show do
121
121
|> limit ( ^ num_results )
122
122
|> Repo . all ( )
123
123
end
124
-
125
- defp error_has_source_info? ( % Error { source_function: "-" , source_line: "-" } ) , do: false
126
- defp error_has_source_info? ( % Error { } ) , do: true
127
124
end
Original file line number Diff line number Diff line change 19
19
< pre class = "overflow-auto p-4 rounded-lg bg-gray-300/10 border border-gray-900 " > <%= @ occurrence . reason %> </ pre >
20
20
</ . section >
21
21
22
- < . section :if = { error_has_source_info ?( @ error ) } title = "Source " >
22
+ < . section :if = { ErrorTracker.Error . has_source_info ?( @ error ) } title = "Source " >
23
23
< pre class = "overflow-auto text-sm p-4 rounded-lg bg-gray-300/10 border border-gray-900 " >
24
24
<%= sanitize_module ( @ error . source_function ) %>
25
25
<%= @ error . source_line %> </ pre >
You can’t perform that action at this time.
0 commit comments