BackgroundFaultMonitor Class#
Catches failures that happen on work a cell started but did not wait for, and routes them to the notebook they most likely belong to.
Cell code can start a task or a thread and return before it finishes. When that work then throws, the exception has nowhere to go: the cell has already been answered, so no result can carry it. Left alone, .NET discards an unobserved task exception silently, which is how a notebook can look entirely successful while its work failed.
The runtime reports such a failure with no indication of which notebook it came from, and by then the work that raised it is gone. So a fault goes to the one notebook that is inside a cell when it surfaces, which is the only case where the answer is knowable, and otherwise to every open notebook. Reporting it in more places than it belongs is the right way to be wrong: a failure nobody is told about is exactly what this exists to prevent.
public static class BackgroundFaultMonitor
Inheritance System.Object → BackgroundFaultMonitor
Methods#
Drain() Method#
Takes the faults raised while no notebook was open. A host with no notebook of its own calls this to report what it collected.
public static System.Collections.Generic.IReadOnlyList<Verso.Abstractions.CellOutput> Drain();
Returns#
System.Collections.Generic.IReadOnlyList<CellOutput>
Install() Method#
Starts watching, once per process. Hosts call this during startup; calling it again does nothing, so every entry point can call it without coordinating.
public static void Install();
Record(string, Exception) Method#
Records a fault against whichever notebook it most likely belongs to. See the remarks on this class for how that is decided.
public static void Record(string kind, System.Exception? exception);
Parameters#
kind System.String
exception System.Exception
Register(BackgroundFaultSink) Method#
Starts reporting faults to a notebook's sink. Disposing the result stops it, which matters because a fault raised after a notebook closes must not be held for a queue nobody drains.
public static System.IDisposable Register(Verso.Execution.BackgroundFaultSink sink);
Parameters#
sink BackgroundFaultSink