Merge pull request #31 from vicr123/master

Catch exception when a command throws an unhandled exception
This commit is contained in:
Michael VanOverbeek 2017-01-11 08:42:41 -05:00 committed by GitHub
commit 5b71be06a2
4 changed files with 10 additions and 2 deletions

View file

@ -176,6 +176,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.",
@ -236,4 +237,4 @@ If a system file is deleted by the virus scanner, it will be replaced.",
"{DIALOG_NAME}":"Dialog",
"{COLOR_PICKER_NAME}":"Color Picker",
"{CHAT_NAME}":"Chat",
}
}

View file

@ -286,7 +286,6 @@ namespace ShiftOS.Engine {
}
}
[Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")]
public static bool Help() {
var asm = Assembly.GetExecutingAssembly();

View file

@ -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.",

View file

@ -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[] { });