Catch exception when a command throws an unhandled exception
This commit is contained in:
parent
5958b0acff
commit
627c456172
3 changed files with 8 additions and 1 deletions
|
@ -286,7 +286,6 @@ namespace ShiftOS.Engine {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")]
|
||||
public static bool Help() {
|
||||
var asm = Assembly.GetExecutingAssembly();
|
||||
|
|
|
@ -175,6 +175,7 @@ If a system file is deleted by the virus scanner, it will be replaced.",
|
|||
"{COMMAND_DEV_MULTARG_DESCRIPTION}":"A command which requiers multiple arguments",
|
||||
|
||||
"{ERR_COMMAND_NOT_FOUND}":"Command not found.",
|
||||
"{ERROR_EXCEPTION_THROWN_IN_METHOD}":"An error occurred within the command. Error details:",
|
||||
"{MUD_ERROR}":"MUD error",
|
||||
|
||||
"{PROLOGUE_NO_USER_DETECTED}":"No user detected. Please enter a username.",
|
||||
|
|
|
@ -210,6 +210,13 @@ namespace ShiftOS.Engine
|
|||
{
|
||||
return (bool)method.Invoke(null, new[] { args });
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}"));
|
||||
Console.WriteLine(e.InnerException.Message);
|
||||
Console.WriteLine(e.InnerException.StackTrace);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (bool)method.Invoke(null, new object[] { });
|
||||
|
|
Reference in a new issue