/// <summary> /// Handles an exception thrown when loading a mod. /// </summary> /// <param name="ex">The exception thrown.</param> internal static void HandleModException(object ex) { if (ex is Exception e) { string title = CurrentModTitle; if (!string.IsNullOrEmpty(title)) { DebugLogger.LogDebug("When loading mod {0}:", title); } DebugLogger.LogException(e); } }
/// <summary> /// Loads the sprites if they are not already loaded. /// </summary> private static void LoadSprites() { if (!spritesLoaded) { try { MODS_BOTTOM = LoadSprite("icon_mods_bottom"); MODS_TOP = LoadSprite("icon_mods_top"); } catch (ArgumentException e) { // Could not load the icons, but better this than crashing DebugLogger.LogException(e); } spritesLoaded = true; } }
/// <summary> /// Logs exceptions where some types in an assembly fail to load, and adds the types /// that did load to the list anyways. /// </summary> /// <param name="exception">The exception thrown.</param> /// <param name="assembly">The assembly that failed to fully load.</param> /// <param name="types">The location to store types that did load.</param> private static void HandleTypeLoadExceptions(ReflectionTypeLoadException exception, Assembly assembly, ICollection <Type> types) { var failedTypes = exception?.Types; DebugLogger.LogError("Error when loading types from " + assembly.FullName); if (failedTypes != null) { int n = failedTypes.Length; for (int i = 0; i < n; i++) { var type = failedTypes[i]; var thrown = exception.LoaderExceptions[i]; if (type != null) { types.Add(type); } else if (thrown != null) { DebugLogger.LogException(thrown); } } } }
/// <summary> /// Applied before LogException runs. /// </summary> internal static bool Prefix(Exception e, string errorMessage) { DebugLogger.LogError(errorMessage); DebugLogger.LogException(e); return(false); }
public void LogException(Exception exception, UnityEngine.Object context) { DebugLogger.LogException(exception); }