Consistent error infrastructure for the beme reader/tokenizer.
All error throw sites should use beme-error to ensure uniform
location tracking and message formatting.
Consistent error infrastructure for the beme reader/tokenizer. All error throw sites should use `beme-error` to ensure uniform location tracking and message formatting.
(beme-error msg)(beme-error msg {:keys [line col cause source] :as data})Throw a beme reader/tokenizer error with consistent structure. data may contain :line, :col (1-indexed), :cause, and :source. :source-context is added to ex-data when both :source and :line are present. :source and :cause are always excluded from ex-data.
Throw a beme reader/tokenizer error with consistent structure. data may contain :line, :col (1-indexed), :cause, and :source. :source-context is added to ex-data when both :source and :line are present. :source and :cause are always excluded from ex-data.
(format-error e)(format-error e source)Format an exception for display, optionally with source context. Shows multi-line context with line numbers, span underlines, and secondary locations when available in ex-data.
This function bridges two line models: :line/:col in ex-data come from the scanner (where \r occupies a column), while the display line comes from source-context (which uses str/split-lines, stripping \r from CRLF pairs). For CRLF sources the display line may be shorter than the scanner col implies — span-underline clamps to avoid overrunning the display. Returns a string suitable for printing.
Format an exception for display, optionally with source context. Shows multi-line context with line numbers, span underlines, and secondary locations when available in ex-data. This function bridges two line models: :line/:col in ex-data come from the scanner (where \r occupies a column), while the display line comes from source-context (which uses str/split-lines, stripping \r from CRLF pairs). For CRLF sources the display line may be shorter than the scanner col implies — span-underline clamps to avoid overrunning the display. Returns a string suitable for printing.
(source-context source line)Extract the source line at the given 1-indexed line number for display. Uses str/split-lines which splits on \n and \r\n (stripping \r from CRLF pairs). This is the display line model — it may differ from the scanner line model (beme.alpha.scan.source/line-col->offset) which treats \r as a regular character. The difference only matters for CRLF sources. Returns nil if source is nil/blank, line is nil, or line is out of range.
Extract the source line at the given 1-indexed line number for display. Uses str/split-lines which splits on \n and \r\n (stripping \r from CRLF pairs). This is the *display* line model — it may differ from the scanner line model (beme.alpha.scan.source/line-col->offset) which treats \r as a regular character. The difference only matters for CRLF sources. Returns nil if source is nil/blank, line is nil, or line is out of range.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |