Obscura.Diagnostic (obscura v0.1.0)

Copy Markdown View Source

Structured, report-safe diagnostic returned by optional runtime setup paths.

Diagnostics keep a stable machine-readable code while giving callers an actionable message and remediation. They never contain analyzed source text.

Summary

Functions

Returns the stable diagnostic codes supported by public setup boundaries.

Returns a concise human-readable diagnostic without rendering the nested cause.

Builds a diagnostic with a default remediation for the code.

Converts common legacy reasons into a structured diagnostic.

Returns the default remediation for a diagnostic code.

Converts a diagnostic to a JSON-safe map without path or nested-cause data.

Types

t()

@type t() :: %Obscura.Diagnostic{
  asset: atom() | nil,
  backend: atom() | nil,
  cause: term(),
  code: atom(),
  component: atom() | nil,
  dependency: atom() | nil,
  message: String.t(),
  metadata: map(),
  path: String.t() | nil,
  profile: atom() | nil,
  remediation: String.t()
}

Functions

codes()

@spec codes() :: [atom()]

Returns the stable diagnostic codes supported by public setup boundaries.

format(diagnostic)

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

Returns a concise human-readable diagnostic without rendering the nested cause.

new(code, attrs \\ [])

@spec new(
  atom(),
  keyword()
) :: t()

Builds a diagnostic with a default remediation for the code.

normalize(diagnostic, attrs)

@spec normalize(
  term(),
  keyword()
) :: t()

Converts common legacy reasons into a structured diagnostic.

remediation(code)

@spec remediation(atom()) :: String.t()

Returns the default remediation for a diagnostic code.

to_map(diagnostic)

@spec to_map(t()) :: map()

Converts a diagnostic to a JSON-safe map without path or nested-cause data.