View Source cure_error_reporter (cure v0.1.0)

Cure Error Reporter

Enhanced error reporting module with precise location tracking and user-friendly diagnostic messages. This module provides rich error formatting for parser, lexer, and semantic analysis errors.

Features

  • Rich Location Info: Line, column, and file context
  • Snippet Display: Show source code around errors
  • Suggestions: Provide helpful hints for common mistakes
  • Color Formatting: Terminal color support for better readability
  • Multi-error Support: Report multiple errors in batch

Summary

Functions

create_diagnostic(Severity, Location, Message, Suggestions)

-spec create_diagnostic(error | warning | info,
                        #location{line :: term(), column :: term(), file :: term()},
                        binary(),
                        [binary()]) ->
                           #diagnostic{severity :: error | warning | info,
                                       location ::
                                           #location{line :: term(), column :: term(), file :: term()},
                                       message :: binary(),
                                       snippet :: binary() | undefined,
                                       suggestions :: [binary()]}.

format_error(Error, Location)

-spec format_error(term(), #location{line :: term(), column :: term(), file :: term()}) -> binary().

format_error/3

-spec format_error(term(), #location{line :: term(), column :: term(), file :: term()}, map()) ->
                      binary().

format_parse_error(Reason, Line, Column, File)

-spec format_parse_error(term(), integer(), integer(), string() | undefined) -> binary().

format_type_error(Reason, Location, Expected, Got)

-spec format_type_error(term(),
                        #location{line :: term(), column :: term(), file :: term()},
                        term(),
                        term()) ->
                           binary().

format_with_snippet/3

-spec format_with_snippet(term(), #location{line :: term(), column :: term(), file :: term()}, binary()) ->
                             binary().