caffeine_lang/rich_error

Types

Machine-readable error code.

pub type ErrorCode {
  ErrorCode(phase: String, number: Int)
}

Constructors

  • ErrorCode(phase: String, number: Int)

An enriched error with structured location and diagnostic data.

pub type RichError {
  RichError(
    error: errors.CompilationError,
    code: ErrorCode,
    source_path: option.Option(String),
    source_content: option.Option(String),
    location: option.Option(errors.SourceLocation),
    suggestion: option.Option(String),
  )
}

Constructors

Values

pub fn error_code_for(
  error: errors.CompilationError,
) -> ErrorCode

Assigns an error code based on the CompilationError variant.

pub fn error_code_to_string(code: ErrorCode) -> String

Converts an ErrorCode to its display string (e.g., “E103”).

pub fn error_message(error: errors.CompilationError) -> String

Extracts the human-readable message from a CompilationError. Delegates to errors.to_message for consistent behavior.

pub fn from_compilation_error(
  error: errors.CompilationError,
) -> RichError

Creates a RichError, extracting context from the error’s ErrorContext.

pub fn from_compilation_errors(
  error: errors.CompilationError,
) -> List(RichError)

Flattens a CompilationError into a list of RichErrors. Unwraps CompilationErrors into individual RichErrors.

Search Document