ToolCall.Diagnostic (ToolCall v0.4.0)

Copy Markdown

A structured compile-time diagnostic returned by a function-declaration source.

line and column point at the declaration that produced the diagnostic, such as the @spec line, and are optional: a source that cannot locate its input leaves them nil and the builder falls back to the definition location.

severity decides what the builder does with it: :warning is reported and the affected tool is skipped, :error fails the compile.

Summary

Types

location()

@type location() :: [line: pos_integer(), column: pos_integer()]

severity()

@type severity() :: :warning | :error

t()

@type t() :: %ToolCall.Diagnostic{
  column: pos_integer() | nil,
  line: pos_integer() | nil,
  message: String.t(),
  severity: severity()
}

Functions

error(message, location \\ [])

@spec error(String.t(), location()) :: t()

message(diagnostic)

@spec message(t()) :: String.t()

position(diagnostic)

@spec position(t()) :: {pos_integer() | nil, pos_integer() | nil} | nil

Returns the diagnostic's own {line, column}, or nil when unknown.

warning(message, location \\ [])

@spec warning(String.t(), location()) :: t()