diff options
| author | Victor Tran <[email protected]> | 2017-01-11 14:22:12 +1100 |
|---|---|---|
| committer | Victor Tran <[email protected]> | 2017-01-11 14:22:12 +1100 |
| commit | 627c4561722cf829a21c95554f79260f955e5139 (patch) | |
| tree | 6e52d32ae69cf2d3613c6f09c5be9c35358e1fd5 | |
| parent | 5958b0acff0227648e89abe89b91e8b4c48d253e (diff) | |
| download | shiftos_thereturn-627c4561722cf829a21c95554f79260f955e5139.tar.gz shiftos_thereturn-627c4561722cf829a21c95554f79260f955e5139.tar.bz2 shiftos_thereturn-627c4561722cf829a21c95554f79260f955e5139.zip | |
Catch exception when a command throws an unhandled exception
| -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 |
3 files changed, 8 insertions, 1 deletions
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[] { }); |
