WplAi.Errors.ParseError (WPL-AI v1.7.0)

Copy Markdown View Source

Error during parsing

Summary

Functions

Emitted when a WEEK N: block contains content that is not a valid DAY block (e.g. the LLM wrote Monday: walk/run as an inline summary instead of DAY Monday training 45m "..."). Without this error the parser silently discarded the malformed week body, the compiler produced a week with empty days, and only the downstream :phase_duration_mismatch validator caught the gap.

Types

error_type()

@type error_type() ::
  :unexpected_token
  | :unexpected_eof
  | :missing_required
  | :invalid_value
  | :invalid_keyword
  | :duplicate_section
  | :invalid_structure
  | :unknown_exercise_ref
  | :week_has_no_valid_days

repair_hint()

@type repair_hint() :: %{
  optional(:action) => atom(),
  optional(:target_path) => String.t(),
  optional(:parent_name) => String.t() | nil,
  optional(:missing) => [String.t() | non_neg_integer()] | nil,
  optional(:expected_count) => non_neg_integer() | nil,
  optional(:actual_count) => non_neg_integer() | nil,
  optional(:allowed_values) => [String.t()] | nil,
  optional(:expected_shape) => String.t() | nil,
  optional(:context_dsl_example) => String.t() | nil
}

t()

@type t() :: %WplAi.Errors.ParseError{
  expected: [String.t()] | nil,
  got: String.t() | nil,
  location: WplAi.Errors.Location.t() | nil,
  message: String.t(),
  repair_hint: repair_hint() | nil,
  suggestions: [String.t()] | nil,
  type: error_type()
}

Functions

duplicate_section(section, location)

invalid_keyword(keyword, context, location, valid_keywords)

invalid_structure(message, location)

invalid_value(field, value, valid_values, location)

missing_required(field, section, location)

new(type, message, opts \\ [])

unexpected_eof(expected)

unexpected_token(expected, got, location)

unknown_exercise_ref(ref, location, suggestions \\ [])

week_has_no_valid_days(week_number, got_token, location)

Emitted when a WEEK N: block contains content that is not a valid DAY block (e.g. the LLM wrote Monday: walk/run as an inline summary instead of DAY Monday training 45m "..."). Without this error the parser silently discarded the malformed week body, the compiler produced a week with empty days, and only the downstream :phase_duration_mismatch validator caught the gap.

Mirrors the TypeScript factory weekHasNoValidDays in @gymbile/wpl-ai 1.11.0.