thrift_generator_diagnostic (thrift_generator v0.7.0)

View Source

Error rendering shared by the CLI and the rebar3 plugin.

Located problems — lexer/parser errors and the semantic pass findings, both carrying a file path and a location — render in the rebar3/elp style: a source excerpt with a gutter and a ╰── marker naming the problem. Locations may carry a column ({Line, Column} pairs thread through from the lexer); the marker then sits on the exact column, counted in codepoints of the tab-expanded line, falling back to the first non-blank column for line-only locations. When the source cannot be read back, carries no such line, or the error names no location at all, the compact path:line[:column]: message form answers instead. The source lookup is injectable — tests and the --compact-errors switch feed a resolver that always errors.

Summary

Types

loc()

-type loc() :: integer() | {integer(), integer()}.

source_fun()

-type source_fun() :: auto | fun((unicode:chardata()) -> {ok, binary()} | {error, term()}).

Functions

format(Reason)

-spec format(term()) -> unicode:chardata().

format/2

-spec format(term(), source_fun()) -> unicode:chardata().