defmodule Rollbax do use Application def start(_type, _args) do import Supervisor.Spec enabled = get_config(:enabled, true) token = fetch_config(:access_token) envt = fetch_config(:environment) children = [ worker(Rollbax.Client, [token, envt, enabled]) ] Supervisor.start_link(children, strategy: :one_for_one) end defp get_config(key, default) do Application.get_env(:rollbax, key, default) end defp fetch_config(key) do case get_config(key, :not_found) do :not_found -> raise ArgumentError, "the configuration parameter #{inspect(key)} is not set" value -> value end end def report(exception, stacktrace, meta \\ %{}) when is_list(stacktrace) and is_map(meta) do message = Exception.format(:error, exception, stacktrace) Rollbax.Client.emit(:error, message, meta) end end