Packages

Elixir framework for building production-ready AI agents and LLM applications: type-safe schemas with JSON Schema generation, tool calling, streaming, multi-agent coordination, guardrails, and distributed fault-tolerant sessions, with first-class Anthropic Claude support.

Current section

Files

Jump to
normandy lib normandy guardrails violation_error.ex
Raw

lib/normandy/guardrails/violation_error.ex

defmodule Normandy.Guardrails.ViolationError do
@moduledoc """
Exception raised when an input guardrail rejects an agent's input.
Modeled on `Normandy.Schema.ValidationError` so callers that already handle
validation errors can rescue the two uniformly if desired.
"""
defexception [:message, :violations]
@type t :: %__MODULE__{
message: String.t(),
violations: [map()]
}
@impl true
def exception(opts) do
message = Keyword.get(opts, :message, "Guardrail violation")
violations = Keyword.get(opts, :violations, [])
%__MODULE__{
message: message,
violations: violations
}
end
end