Class TimbnSafe
Runs a handler and logs a throw instead of letting it reach the game, in one wording for all of Core and the mods. Use it around any code a game event or a callback runs, since a throw that reaches the game can drop the handler for the rest of the session or stop a frame half done.
public static class TimbnSafe
- Inheritance
-
TimbnSafe
- Inherited Members
Methods
Run(Action?, ManualLogSource, string)
Runs the code and logs a throw as an error naming what threw.
public static bool Run(Action? action, ManualLogSource logger, string what)
Parameters
actionActionThe code to run. Null counts as having run.
loggerManualLogSourceThe plugin's Logger, so the line shows under the plugin's name.
whatstringWhat the code is, for the log line, such as a class and what it was doing.
Returns
- bool
True when the code ran through, false when it threw.
Examples
TimbnSafe.Run(LoadPacks, Logger, $"{nameof(QuestPacks)}|Loading the quest packs");