diff options
| author | Michael VanOverbeek <[email protected]> | 2017-01-11 08:42:41 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-01-11 08:42:41 -0500 |
| commit | 5b71be06a2efc42acf1af22a63730a947d7a1978 (patch) | |
| tree | a5adbe0242ae43f06034113d383ad002bc73d36e | |
| parent | 5958b0acff0227648e89abe89b91e8b4c48d253e (diff) | |
| parent | 32fc0f960d99af9345cc920ccefb5f4b55e5c92b (diff) | |
| download | shiftos_thereturn-5b71be06a2efc42acf1af22a63730a947d7a1978.tar.gz shiftos_thereturn-5b71be06a2efc42acf1af22a63730a947d7a1978.tar.bz2 shiftos_thereturn-5b71be06a2efc42acf1af22a63730a947d7a1978.zip | |
Merge pull request #31 from vicr123/master
Catch exception when a command throws an unhandled exception
| -rw-r--r-- | ShiftOS.WinForms/Resources/strings_en.txt | 3 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Commands.cs | 1 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Resources/strings_en.txt | 1 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/TerminalBackend.cs | 7 |
4 files changed, 10 insertions, 2 deletions
diff --git a/ShiftOS.WinForms/Resources/strings_en.txt b/ShiftOS.WinForms/Resources/strings_en.txt index 032a554..54c9b54 100644 --- a/ShiftOS.WinForms/Resources/strings_en.txt +++ b/ShiftOS.WinForms/Resources/strings_en.txt @@ -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", -}
\ No newline at end of file +} diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 4571387..9822c1c 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -286,7 +286,6 @@ namespace ShiftOS.Engine { } } - [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help() { var asm = Assembly.GetExecutingAssembly(); diff --git a/ShiftOS_TheReturn/Resources/strings_en.txt b/ShiftOS_TheReturn/Resources/strings_en.txt index 6cd1be0..c42edab 100644 --- a/ShiftOS_TheReturn/Resources/strings_en.txt +++ b/ShiftOS_TheReturn/Resources/strings_en.txt @@ -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.", diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 70cb25d..bba5510 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -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[] { }); |
