Skip to main content

Module crash

Module crash 

Source
Expand description

Crash reports (ADR-0079): what a backend’s panic hook writes through the game’s Storage, and what the game hears of it at its next start (Setup::last_crash).

A report (CrashReport) is stored at crash-<when> (crash_key), when being milliseconds since 1970 on the backend’s clock. It holds the panic’s message, place, thread and backtrace, the engine’s, the game’s and the target’s versions, the frame and the screen that was running, the last lines of the log and the game’s own record of its play. It never holds the player’s settings, saves or keymap, nor what the player typed unless the game’s record holds it. Reports stay on the machine.

A report is a record in storage, like the settings and the profiles, not an asset kind a game ships, so no format is registered for it. Its reader (CrashReport::parse) still keeps ADR-0007 §5: a size limit, errors and never a panic.

Structs§

CrashReport
What a backend’s panic hook found: plain data, written with to_text and read with parse. Every field but version and message may be missing from a report’s text, so a newer field never stops an older report from reading.
LastCrash
What a game hears at its start of the last crash: when, the message and the place, and the report’s key in its storage. What the player sees of it, if anything, is the game’s to word.

Constants§

BACKTRACE_BYTES
The longest backtrace kept, in bytes.
ENGINE_VERSION
The engine’s version a report names: every shuyi-* crate has the workspace’s.
LOG_LINES
The most lines of the log kept: the last ones.
LOG_LINE_BYTES
The longest line of the log kept, in bytes.
MESSAGE_BYTES
The longest message kept, in bytes.
OFFERED_KEY
The key that names the last report offered to the game (offer_last_crash).
RECORD_BYTES
The longest record of the game’s play kept, in bytes: a longer one is left out (CrashReport::set_record).
REPORT_VERSION
The version of the report’s text this build writes.
TEXT_BYTES
The longest text CrashReport::parse reads, in bytes.

Functions§

crash_key
The key a report made at when is stored at: crash-<when>.
keep_newest
Deletes all but the newest n reports in storage.
offer_last_crash
The newest fatal report in storage newer than the one OFFERED_KEY names; from then on it names the newest report, so each is offered or skipped once. A report that isn’t fatal, or doesn’t read, is skipped.
report_keys
The keys of the reports in storage, newest first. Every other key is ignored, and a storage that can’t list gives none.
report_when
When the report at key was made, if key is a report’s: crash- and digits only.