|
| 1 | +namespace MsieJavaScriptEngine.ActiveScript |
| 2 | +{ |
| 3 | + using System.Text; |
| 4 | + |
| 5 | + using Resources; |
| 6 | + |
| 7 | + /// <summary> |
| 8 | + /// Responsible for formatting Active Script Error Message |
| 9 | + /// </summary> |
| 10 | + public static class ActiveScriptErrorFormatter |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// Generates a detailed error message |
| 14 | + /// </summary> |
| 15 | + /// <param name="activeScriptException">Active script exception</param> |
| 16 | + /// <param name="filePath">File path</param> |
| 17 | + /// <returns>Detailed error message</returns> |
| 18 | + public static string Format(ActiveScriptException activeScriptException, string filePath) |
| 19 | + { |
| 20 | + var errorMessage = new StringBuilder(); |
| 21 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message, |
| 22 | + activeScriptException.Message); |
| 23 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorCode, |
| 24 | + activeScriptException.ErrorCode); |
| 25 | + if (activeScriptException.ErrorWCode != 0) |
| 26 | + { |
| 27 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorWCode, |
| 28 | + activeScriptException.ErrorWCode); |
| 29 | + } |
| 30 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Subcategory, |
| 31 | + activeScriptException.Subcategory); |
| 32 | + if (!string.IsNullOrWhiteSpace(activeScriptException.HelpLink)) |
| 33 | + { |
| 34 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_HelpKeyword, |
| 35 | + activeScriptException.HelpLink); |
| 36 | + } |
| 37 | + errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_File, filePath); |
| 38 | + |
| 39 | + return errorMessage.ToString(); |
| 40 | + } |
| 41 | + } |
| 42 | +} |
0 commit comments