Skip to main content

Module error

Module error 

Source

Structs§

Error
LogState
MacroDiagGuard
RAII marker: “the log record currently being emitted comes from a diagnostic macro that already counted itself via note_status”.
ReportCounts
A thread-portable snapshot of the REPORT’s integer status counters (everything EXCEPT the arena-SymStr-keyed undefined/missing maps, whose keys are interner ids local to one thread’s arena). Used to forward a worker thread’s diagnostic tally back to the main thread: REPORT is #[thread_local], so an Error!/Warn! raised on a spawned post-processing worker increments only that worker’s counters and is invisible to the main-thread status_code unless merged here. See crate::util::logger::capture / crate::util::logger::replay_captured.

Enums§

ErrorCategory
ErrorTarget
LogStatus

Constants§

MAX_CONSECUTIVE_ERRORS
Threshold for “same error fired this many times in a row → bail.” Set well above any legitimate same-error pattern (a paper with 500+ identical errors would already be near-useless output) but well below the 10000 MAX_ERRORS cap so runaway papers don’t accumulate huge noise logs. Empirically, the pathological \tabalign-in-math-mode runaway hits >9000 consecutive same errors; this catches that at 500 instead. The threshold was tightened from an initial 2000 after verifying no test in the 1112-test suite exceeds it.

Statics§

REPORT

Functions§

clear_fatal_flag
Clear the sticky report.fatal flag. Used by best-effort helpers (e.g. \maketitle’s deferred frontmatter digest) that silently swallow a digest error and want to undo the note_status(Fatal) side-effect so the overall conversion status reflects the silently-handled fact.
conversion_status_line
Build a status message matching Perl’s getStatusMessage(). Format: “N warnings; M errors; K fatal error; L undefined macros[\foo, \bar]; P missing files[x.sty]” Returns “No obvious problems” when no issues detected. The canonical machine-readable conversion-status line, Status:conversion:N.
conversion_verdict
The human-readable end-of-run verdict: Conversion complete|failed: <counts>.
debug_enabled
Perl: truthiness of $LaTeXML::DEBUG{$name}.
debug_fatal_enabled
One shared probe for the LATEXML_DEBUG_FATAL diagnostics (first-fatal backtrace, gullet pushback dump, recent-token ring). Lazy-cached so hot paths pay a single bool test, and a single seam if the env contract grows (PR #249 review P3-13).
debuggable_feature
Perl: DebuggableFeature($name) — register a feature name so it can be listed/validated for --debug.
emit_error
See emit_info. Unlike the Error! macro this cannot escalate by returning — there is no Err channel in the contexts it serves — so when the error count or the consecutive-error count crosses its cap it emits the Fatal:TooManyErrors record and latches the sticky fatal instead: the run continues (its caller has no unwind path) but the conversion’s verdict and status code report the fatal honestly.
emit_fatal
See emit_info. Latches the sticky fatal and emits the canonical Fatal:<category>:<object> line — NEVER suppressed (see emit_record). The CALLER owns any early-exit control flow (e.g. latexml_post’s Fatal! returns its own PostError after this) — a fatal, unlike an error, needs no cap bookkeeping.
emit_info
The single diagnostic vehicle, function form — for contexts that cannot use the Error!/Warn!/Info! macros because those are return-based (Error! escalates to Fatal!, which return Err(...)s, so it only typechecks in Result<_, error::Error> functions).
emit_record
The ONE emission primitive every diagnostic flows through (DRY pass, user directive 2026-08-02): count on the emitting thread’s REPORT, then log with the pre-formatted target, respecting output suppression — EXCEPT for Error and Fatal records, which are emitted UNCONDITIONALLY (user decision 2026-08-03): frameworks such as cortex aggregate success rates from Error:/Fatal: lines, so muting either would hide exactly the signal they measure. Suppression mutes Debug/Info/Warning only. The MacroDiagGuard marks the emission so the logger backend does not count it a second time.
emit_warn
See emit_info.
enable_debug_feature
Perl: $LaTeXML::DEBUG{$name} = 1 — called by the CLI per --debug NAME.
get_status
get_status_code
Compute the status code from the report state (Perl getStatusCode). 3 = fatal, 2 = errors, 1 = warnings, 0 = clean.
get_status_message
initialize_report
is_demote_fatals
Returns true if Fatal! is currently demoted to Error.
is_log_output_suppressed
Returns true if log output is currently suppressed.
known_debug_features
All registered feature names (sorted), for --debug diagnostics.
macro_diag_guard
merge_report_counts
Add a worker thread’s ReportCounts into the current (main) thread’s REPORT. Only the integer counts + the sticky fatal flag are merged; the arena-keyed undefined/missing maps are NOT (a worker has its own thread-local arena, so those keys are not portable).
note_begin
Open a named progress stage, logging (stage....
note_consecutive_error
Record an error signature; returns the new consecutive count. Call from the Error! macro after note_status. Resets count to 1 on a different signature, increments on a match.
note_end
Close the progress stage opened by note_begin, logging the matching ).
note_progress
note_progress_detailed
note_status
note_status_from_logger
Count a diagnostic record observed by the logger backend, unless it was emitted by a macro (already counted at raise time) or the report is mid-borrow (a raw log call from inside a report_mut! scope must not panic the conversion over a tally increment — matching the logger’s own try_borrow discipline for LOG_BUFFER).
progress_step
Advance the progress indicator by one step.
record_last_fatal
Record a fatal into the resource-fatal latch — only Timeout-target fatals with payload-free categories are kept (the latch exists for resource fatals; payload-carrying ErrorCategory variants are not cloneable and are never resource-class).
reset_arena_keyed_reports
Clear the arena-SymStr-keyed report maps (undefined, missing). MUST be called whenever the arena is reset (see crate::reset_thread_engine): their keys are arena interner ids, so after arena::reset() a stale key resolves to whatever string now occupies that id — e.g. a \special_relax family-token name — producing phantom “undefined macro” reports across conversions.
restore_report_counts
Overwrite the current thread’s REPORT counters with a prior snapshot. The isolation primitive for RECURSIVE/auxiliary digestions whose diagnostics must not count against the document (Perl analog: the recursive MakeBibliography session keeps its tally out of the outer document). Pair with set_suppress_log_output so neither the lines nor the counts leak: snapshot -> suppress -> digest -> restore.
set_demote_fatals
Set or clear the fatal-demotion flag. Returns the previous value.
set_suppress_log_output
Set or clear the log-output suppression flag. Returns the previous value.
snapshot_report_counts
Snapshot the current thread’s REPORT integer counters.
take_last_resource_fatal
Take (and clear) the latched resource fatal, if any. Returns the structured Error so a boundary that received only a flattened string can propagate the real thing.

Type Aliases§

Result