Catch exceptions thrown by commands
This commit is contained in:
9
CHANGELOG.md
Normal file
9
CHANGELOG.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Torch 1.0.182.329
|
||||||
|
* Improved logging, logs now to go the Logs folder and aren't deleted on start
|
||||||
|
* Fixed chat tab not enabling with -autostart
|
||||||
|
* Fixed player list
|
||||||
|
* Watchdog time-out is now configurable in TorchConfig.xml
|
||||||
|
* Fixed infinario log spam
|
||||||
|
* Fixed crash when sending empty message from chat tab
|
||||||
|
* Fixed permissions on Torch commands
|
||||||
|
* Changed plugin StoragePath to the current instance path (per-instance configs)
|
@@ -1,4 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.203.595")]
|
[assembly: AssemblyVersion("1.0.207.7")]
|
||||||
[assembly: AssemblyFileVersion("1.0.203.595")]
|
[assembly: AssemblyFileVersion("1.0.207.7")]
|
@@ -1,4 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.1.203.596")]
|
[assembly: AssemblyVersion("1.1.207.7")]
|
||||||
[assembly: AssemblyFileVersion("1.1.203.596")]
|
[assembly: AssemblyFileVersion("1.1.207.7")]
|
@@ -8,6 +8,7 @@ using NLog;
|
|||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Plugins;
|
using Torch.API.Plugins;
|
||||||
using Torch.Commands.Permissions;
|
using Torch.Commands.Permissions;
|
||||||
|
using VRage.Game;
|
||||||
using VRage.Game.ModAPI;
|
using VRage.Game.ModAPI;
|
||||||
|
|
||||||
namespace Torch.Commands
|
namespace Torch.Commands
|
||||||
@@ -26,6 +27,7 @@ namespace Torch.Commands
|
|||||||
private readonly MethodInfo _method;
|
private readonly MethodInfo _method;
|
||||||
private ParameterInfo[] _parameters;
|
private ParameterInfo[] _parameters;
|
||||||
private int? _requiredParamCount;
|
private int? _requiredParamCount;
|
||||||
|
private static readonly Logger Log = LogManager.GetLogger(nameof(Command));
|
||||||
|
|
||||||
public Command(ITorchPlugin plugin, MethodInfo commandMethod)
|
public Command(ITorchPlugin plugin, MethodInfo commandMethod)
|
||||||
{
|
{
|
||||||
@@ -83,6 +85,8 @@ namespace Torch.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool TryInvoke(CommandContext context)
|
public bool TryInvoke(CommandContext context)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var parameters = new object[_parameters.Length];
|
var parameters = new object[_parameters.Length];
|
||||||
|
|
||||||
@@ -110,6 +114,14 @@ namespace Torch.Commands
|
|||||||
_method.Invoke(moduleInstance, parameters);
|
_method.Invoke(moduleInstance, parameters);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
context.Respond(e.Message, "Error", MyFontEnum.Red);
|
||||||
|
Log.Error($"Command '{SyntaxHelp}' from '{Plugin.Name ?? "Torch"}' threw an exception. Args: {string.Join(", ", context.Args)}");
|
||||||
|
Log.Error(e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
|
Reference in New Issue
Block a user