# `Juggernaut.Error`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/error.ex#L1)

An error that stops a task before or instead of a verdict.

The `type` decides the exit code (`Juggernaut.CLI.ExitCode`):

  * `:usage` - a bad flag, an unknown id: exit 2;
  * `:config` - an invalid `.juggernaut.exs` or environment: exit 2;
  * `:infrastructure` - the harness failed (lock held, worker boot, ...): exit 3.

An infrastructure error is never a verdict about the code under test.

# `t`

```elixir
@type t() :: %Juggernaut.Error{
  __exception__: term(),
  details: map(),
  message: String.t(),
  type: type()
}
```

# `type`

```elixir
@type type() :: :usage | :config | :infrastructure
```

# `config`

```elixir
@spec config(String.t(), map()) :: t()
```

A configuration error: invalid `.juggernaut.exs` or refused environment. Exit 2.

# `infrastructure`

```elixir
@spec infrastructure(String.t(), map()) :: t()
```

An infrastructure or harness error. Exit 3, never scored as a verdict.

# `to_map`

```elixir
@spec to_map(t()) :: %{required(String.t()) =&gt; term()}
```

The `error` object of the agent and JSON error document (see the
[agent output guide](agent-output.md)): `type`, `message` and each detail, all under
string keys.

# `usage`

```elixir
@spec usage(String.t(), map()) :: t()
```

A usage error: bad arguments, unknown ids. Exit 2.

---

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