Skip to content

Commit 7c02598

Browse files
tjarrattkrishna1m
andauthored
Improve documentation of ErrorTracker.Error kind field (#154)
We thought about it and came to the conclusion that it would be good to change the type declaration for the module. Open for discussion, because that could potentially be a breaking change of the library if users previously had implementations of `ErrorTracker.Ignorer` that matched on non-string types (although, arguably those implementations would never have worked). This addresses #153. --------- Co-authored-by: Manmohan Krishna <[email protected]>
1 parent 1615c6e commit 7c02598

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

guides/Getting Started.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ The `ErrorTracker.Ignorer` behaviour allows you to ignore errors based on their
191191

192192
When an error is ignored, its occurrences are not tracked at all. This is useful for expected errors that you don't want to store in your database.
193193

194+
For example, if you had an integration with an unreliable third-party system that was frequently timing out, you could ignore those errors like so:
195+
196+
```elixir
197+
defmodule MyApp.ErrorIgnores do
198+
@behaviour ErrorTracker.Ignorer
199+
200+
@impl ErrorTracker.Ignorer
201+
def ignore?(%{kind: "Elixir.UnreliableThirdParty.Error", reason: ":timeout"} = _error, _context) do
202+
true
203+
end
204+
end
205+
```
206+
194207
### Muting Errors
195208

196209
Sometimes you may want to keep tracking error occurrences but avoid receiving notifications about them. For these cases,

lib/error_tracker/schemas/error.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ defmodule ErrorTracker.Error do
1212

1313
use Ecto.Schema
1414

15-
@type t :: %__MODULE__{}
15+
@type t :: %__MODULE__{
16+
kind: String.t(),
17+
reason: String.t(),
18+
source_line: String.t(),
19+
source_function: String.t(),
20+
status: :resolved | :unresolved,
21+
fingerprint: String.t(),
22+
last_occurrence_at: DateTime.t(),
23+
muted: boolean()
24+
}
1625

1726
schema "error_tracker_errors" do
1827
field :kind, :string

0 commit comments

Comments
 (0)