# `Faulty.Filter`
[🔗](https://github.com/Hermanverschooten/faulty/blob/main/lib/faulty/filter.ex#L1)

Behaviour for sanitizing & modifying the error context before it's saved.

    defmodule MyApp.ErrorFilter do
      @behaviour Faulty.Filter

      @impl true
      def sanitize(context) do
        context # Modify the context object (add or remove fields as much as you need.)
      end
    end

Once implemented, include it in the Faulty configuration:

  config :faulty, filter: MyApp.Filter

The context has already been scrubbed of sensitive values by `Faulty.Scrubber`
when the filter is called, unless you set `config :faulty, scrub_pii: false`.

With this configuration in place, the Faulty will call `MyApp.Filter.sanitize/1` to get a context before
saving error occurrence.

> #### A note on performance {: .warning}
>
> Keep in mind that the `sanitize/1` will be called in the context of the Faulty itself.
> Slow code will have a significant impact in the Faulty performance. Buggy code can bring
> the Faulty process down.

# `sanitize`

```elixir
@callback sanitize(context :: map()) :: map()
```

This function will be given an error context to inspect/modify before it's saved.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
