Skip to main content

Module error

Module error 

Source

Structs§

DeferredNote
A progress stage that may not happen: a binding load, whose dispatcher both finds the binding and runs it, where Perl opens (Loading <path>... once FindFile found the .ltxml (Core/Mouth/Binding.pm:31, Package.pm:2336). Its (stage... prints before the first line logged inside it (print_deferred_notes) or at its end if it happened, so what it triggers nests inside it (#945); a stage that did not happen and logged nothing leaves no trace (one that logged a line and then declined still shows its note).
DiagnosticGates
The whole diagnostic tally of this thread: the REPORT plus the gates that live beside it — the consecutive-error runaway tracker, the too-many-errors latch and the Fatal-line dedupe. A discarded speculative scope (logger::DiagnosticsHold) restores all of them together, so the errors it dropped can neither count nor trip a cap that would then mute the document’s own errors.
Error
ErrorData
What an Error says. Boxed there so that a Result costs a pointer: the interpreter’s hottest calls (read_token, read_x_token, an argument’s read) return Results, and at this struct’s size each went through stack memory instead of registers (clippy::result_large_err).
IgnoreDiagnosticsScope
Perl local $LaTeXML::IGNORE_ERRORS = 1 as a scope: ignores diagnostics while alive and restores the previous state on drop — panic-safe, unlike a manual restore after the probed call.
IgnoredRecords
A tally of the Error and Fatal records an ignoring scope dropped.
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 per-thread, 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.
SilenceProgressNotesGuard
The progress notes silenced for a scope and put back as they were when the guard is dropped (a panic unwinding included).
SuppressLogOutputGuard
The log-output suppression flag set for a scope (set_suppress_log_output) and put back as it was when the guard is dropped — at the scope’s end, on an early return or while a panic unwinds — so a scope that fails cannot leave the thread’s later conversions silent (a speculative title-page run, sect05.rs title_page_probe_run, under cortex_worker’s per-paper catch_unwind).

Enums§

ErrorCategory
ErrorTarget
LogStatus

Constants§

APPROXIMATED_MEASURE
The state key of a box whose measure a binding approximates, its value the box’s name: a breakable tcolorbox set as one box (tcolorbox_sty.rs, Perl tcolorbox.sty.ltxml:21). Read by approximated_measure.
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§

any_debug_feature_enabled
Whether any --debug feature is on.
approximated_measure
Where an arithmetic overflow (tex.web §104, §460; etex.ch scan_expr), an Error as TeX’s (OXIDIZED_DESIGN #519), is a Warning: inside a measure a binding approximates (APPROXIMATED_MEASURE) the size is ours, not the author’s (DG 2026-11-13). The detail naming the box, and whether it is the box’s first overflow (its Warning; the ones it cascades into an Info), or None outside one.
check_debuggable
Perl CheckDebuggable (Common/Error.pm L483-492), at the end of a run: name the --debug features no loaded module declared. Tests the declaration, not its description (KNOWN_PERL_ERRORS #1224).
clear_session_warnings
Drop the warnings held for a source that never reached its report (its archive unpacked, then its job failed before the session): a persistent worker’s next paper must not log them as its own. Called as each archive is unpacked.
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). LazyLock-cached so hot paths pay a single bool test, and a single seam if the env contract grows (PR #249 review P3-13).
debug_record_enabled
Would an un-featured Debug-status record actually reach the log right now? True only under --verbose (util/logger.rs debug_all; a --debug feature does not admit them) AND output is not suppressed. The Debug! macro gates message construction on this: the 2026-08-23 audit measured up to ~26% of a build-bound conversion spent serializing node_to_string subtrees into Debug! messages that emit_record then discarded (PERFORMANCE.md, Open levers P0). An atomic load + thread-local read — cheap enough for token-frequency call sites.
debuggable_feature
Perl: DebuggableFeature($name) — register a feature name so it can be listed/validated for --debug.
diagnostics_ignored
Whether an IGNORE_ERRORS-style probing scope is active (see set_ignore_diagnostics).
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. Raises the log floor to Debug so the feature’s records pass; un-featured ones stay --verbose’s (util/logger.rs DEBUG_ALL).
errors_ignored_after_fatal
Whether Error records are dropped: after any Fatal (Perl Error returns at Common/Error.pm:362), or once the error cap or a resource Fatal latched (those latch under an ignoring scope too).
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.
latch_too_many_errors
Latch the too-many-errors state: emit_record drops further Error-level records until the next conversion resets the report. Set by the TooManyErrors Fatal paths (the Error! macro cap and emit_error’s latch); cleared in reset_consecutive_error_tracker.
location_line
A message’s location line, \n\tat <locator>; nothing before the first mouth opens (Perl Error.pm:623).
log_session_warnings
Logs and counts the warnings held for the session (warn_at_session_start), into the log now bound. The report’s reset does it; a run that never resets it (an XML input’s post-processing) calls it once its log is bound.
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).
message_object
A diagnostic’s what field as the log line carries it: without leading blanks, and fallback when that leaves nothing. A field of spaces (an \@latex@error prefix whose indent expanded, 2606.13031) leaves Error:latex: followed by blanks, which a log reader keyed on Error:<category>:<what> misses; Perl prints it as it is. Trailing blanks stay, as Perl’s (mycls) Class mycls Warning (OXIDIZED_DESIGN #1175).
muted_errors
The Errors dropped after a Fatal on this thread so far (see DiagnosticGates::muted_errors).
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_error_cap
The error cap’s bookkeeping after one counted Error (key = category:object): at the crossing of MAX_ERRORS or of the consecutive-error limit, latch TooManyErrors and emit its Fatal (Perl Error.pm L362-372). Shared by emit_error and a replayed deferred error (logger.rs DeferredDiagnostics).
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).
preserve_arena_keyed_reports_across
Run f (which resets the string arena) while preserving REPORT’s undefined and missing tallies: their SymStr keys are materialized to owned strings before f and re-interned into the fresh arena afterwards, so get_status_message / conversion_verdict remain byte-identical after dropping the core engine’s arena between core and post-processing.
print_deferred_notes
Print every begun, unprinted DeferredNote, outermost first: the logger calls it before it writes a line, so the line lands inside them.
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).
rename_deferred_note
Rename the innermost unprinted DeferredNote: a binding’s dispatcher names the file it found (a runtime .rhai binding’s path, #560).
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.
reset_suppress_log_output
Clear the log-output suppression flag, the progress notes’ silence (SilenceProgressNotesGuard; reset_thread_engine) and any DeferredNote a panic left: a fresh conversion on a reused thread logs.
resource_fatal_latched
Whether a resource-class Fatal (timeout, memory budget, runaway limits) has been raised in this conversion — see RESOURCE_FATAL_SEEN.
restore_diagnostic_gates
Restore this thread’s DiagnosticGates from a snapshot.
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.
runaway_message
The message of the consecutive-error cap’s Fatal (the Error! macro) for the error signature key.
runaway_reraise
The consecutive-error cap’s Fatal once the error cap latched (a TooManyErrors Fatal line, the total cap’s or the runaway’s, is printed and counted): an Err marked logged, so no sink prints a line for it; the run’s status is the latched Fatal’s.
save_diagnostic_gates
Snapshot this thread’s DiagnosticGates.
set_demote_fatals
Set or clear the fatal-demotion flag. Returns the previous value.
set_ignore_diagnostics
Perl $LaTeXML::IGNORE_ERRORS (Common/Error.pm L362/L380/L396: Error, Warn and Info all return if $LaTeXML::IGNORE_ERRORS): inside a probing scope every diagnostic is dropped WHOLE — neither its line nor its count — so the log and the status can never disagree about it. This is the only sanctioned way to silence a scope; muting lines while keeping counts (or the reverse) is exactly the log/status inconsistency the pipeline must not produce. Returns the previous value; restore it on every exit path.
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.
spend_too_many_errors
The digestion’s end has taken the latched error cap’s Fatal (core_interface::finish_digestion_fatal, OD #251): an Error! of the phases after it (the build of what was kept, the rewrites, the math) no longer raises it again, as Perl’s Error returns before its cap test once a Fatal set IGNORE_ERRORS (Common/Error.pm:362, :372). Until then the re-raise ends a digestion that swallowed the Fatal, our stand-in for the input hardYankProcessing empties.
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.
too_many_errors_latched
Whether the too-many-errors latch is set (see latch_too_many_errors).
too_many_errors_spent
Whether the latched error cap’s Fatal is spent (see spend_too_many_errors).
unlatch_runaway_fatal
Unlatch the latched resource fatal when it is a runaway limit of the expansion in progress — the pushback, a recursion — for a run the document never makes, discarded with it (title_page_probe_run). A limit of the conversion stays latched as the document’s: its deadline, its memory budget, its token budget, its conditional ids. (The token count itself does not carry past the failed run: reading_from_mouth’s error path resets the gullet’s progress, gullet.rs.) Whether it was one.
unmute_errors_after_caught_fatal
A Fatal a script binding catches is the script’s to handle (DG 2026-11-14, OD #1028): when it set the mute, the later Errors print again; a Fatal the script lets through mutes them at its sink’s log_fatal.
warn_at_session_start
A Warning raised before its conversion’s report starts (a source archive is unpacked, a command-line option is checked, before the session): held, then logged and counted by the next initialize_report on this thread, or by log_session_warnings where post-processing opens the log of a run that has no report reset.

Type Aliases§

Result