Browse Source

Catch potential exceptions

pull/100/head
Meivyn 1 year ago
parent
commit
5d30ef0a24
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
2 changed files with 22 additions and 7 deletions
  1. +10
    -3
      IPA.Loader/Config/Stores/GeneratedStoreImpl/GeneratedStoreImpl.cs
  2. +12
    -4
      IPA/Program.cs

+ 10
- 3
IPA.Loader/Config/Stores/GeneratedStoreImpl/GeneratedStoreImpl.cs View File

@ -34,8 +34,8 @@ namespace IPA.Config.Stores
public static IConfigStore Create(Type type) => Create(type, null);
private static readonly MethodInfo CreateGParent =
typeof(GeneratedStoreImpl).GetMethod(nameof(Create), BindingFlags.NonPublic | BindingFlags.Static, null,
private static readonly MethodInfo CreateGParent =
typeof(GeneratedStoreImpl).GetMethod(nameof(Create), BindingFlags.NonPublic | BindingFlags.Static, null,
CallingConventions.Any, new[] { typeof(IGeneratedStore) }, Array.Empty<ParameterModifier>());
internal static T Create<T>(IGeneratedStore? parent) where T : class => (T)Create(typeof(T), parent);
@ -72,7 +72,14 @@ namespace IPA.Config.Stores
internal static void DebugSaveAssembly(string file)
{
Assembly.Save(file);
try
{
Assembly.Save(file);
}
catch (Exception ex)
{
Logger.Config.Error(ex);
}
}
private static ModuleBuilder? module;


+ 12
- 4
IPA/Program.cs View File

@ -72,7 +72,7 @@ namespace IPA
}
PatchContext? context = null;
Assembly? AssemblyLibLoader(object? source, ResolveEventArgs e)
{
// ReSharper disable AccessToModifiedClosure
@ -329,8 +329,16 @@ namespace IPA
Debug.Assert(targetFile.Directory != null, "targetFile.Directory != null");
targetFile.Directory?.Create();
LineBack();
ClearLine();
try
{
LineBack();
ClearLine();
}
catch (Exception ex)
{
// Might throw IOException due to an invalid handle when accessing IsConsole from a MSBuild task.
}
Console.WriteLine(@"Copying {0}", targetFile.FullName);
backup.Add(targetFile);
_ = fi.CopyTo(targetFile.FullName, true);
@ -366,7 +374,7 @@ namespace IPA
/// Encodes an argument for passing into a program
/// </summary>
/// <param name="original">The value_ that should be received by the program</param>
/// <returns>The value_ which needs to be passed to the program for the original value_
/// <returns>The value_ which needs to be passed to the program for the original value_
/// to come through</returns>
public static string EncodeParameterArgument(string original)
{


Loading…
Cancel
Save