@@ -41,21 +41,13 @@ static ProgramLogger()
4141 }
4242
4343 /// <summary>
44- /// Please follow exception format, there are four parts to an error message that need to be specified:
45- /// |class name|calling method name|loading program path|user friendly message that explains the error
46- /// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
44+ /// Logs an exception
4745 /// </summary>
4846 [ MethodImpl ( MethodImplOptions . Synchronized ) ]
49- internal static void LogException ( string message , Exception e )
47+ internal static void LogException ( string classname , string callingMethodName , string loadingProgramPath ,
48+ string interpretationMessage , Exception e )
5049 {
51- //Index 0 is always empty.
52- var parts = message . Split ( '|' ) ;
53- var classname = parts [ 1 ] ;
54- var callingMethodName = parts [ 2 ] ;
55- var loadingProgramPath = parts [ 3 ] ;
56- var interpretationMessage = parts [ 4 ] ;
57-
58- Debug . WriteLine ( $ "ERROR{ message } ") ;
50+ Debug . WriteLine ( $ "ERROR{ classname } |{ callingMethodName } |{ loadingProgramPath } |{ interpretationMessage } ") ;
5951
6052 var logger = LogManager . GetLogger ( "" ) ;
6153
@@ -79,16 +71,16 @@ internal static void LogException(string message, Exception e)
7971 calledMethod = string . IsNullOrEmpty ( calledMethod ) ? "Not available" : calledMethod ;
8072
8173 logger . Error ( $ "\n Exception full name: { e . GetType ( ) . FullName } "
82- + $ "\n Error status: { errorStatus } "
83- + $ "\n Class name: { classname } "
84- + $ "\n Calling method: { callingMethodName } "
85- + $ "\n Program path: { loadingProgramPath } "
86- + $ "\n InnerException number: { innerExceptionNumber } "
87- + $ "\n Exception message: { e . Message } "
88- + $ "\n Exception error type: HResult { e . HResult } "
89- + $ "\n Exception thrown in called method: { calledMethod } "
90- + $ "\n Possible interpretation of the error: { interpretationMessage } "
91- + $ "\n Possible resolution: { possibleResolution } ") ;
74+ + $ "\n Error status: { errorStatus } "
75+ + $ "\n Class name: { classname } "
76+ + $ "\n Calling method: { callingMethodName } "
77+ + $ "\n Program path: { loadingProgramPath } "
78+ + $ "\n InnerException number: { innerExceptionNumber } "
79+ + $ "\n Exception message: { e . Message } "
80+ + $ "\n Exception error type: HResult { e . HResult } "
81+ + $ "\n Exception thrown in called method: { calledMethod } "
82+ + $ "\n Possible interpretation of the error: { interpretationMessage } "
83+ + $ "\n Possible resolution: { possibleResolution } ") ;
9284
9385 innerExceptionNumber ++ ;
9486 e = e . InnerException ;
@@ -97,6 +89,29 @@ internal static void LogException(string message, Exception e)
9789 logger . Error ( "------------- END Wox.Plugin.Program exception -------------" ) ;
9890 }
9991
92+ /// <summary>
93+ /// Please follow exception format: |class name|calling method name|loading program path|user friendly message that explains the error
94+ /// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
95+ /// </summary>
96+ [ MethodImpl ( MethodImplOptions . Synchronized ) ]
97+ internal static void LogException ( string message , Exception e )
98+ {
99+ //Index 0 is always empty.
100+ var parts = message . Split ( '|' ) ;
101+ if ( parts . Length < 4 )
102+ {
103+ var logger = LogManager . GetLogger ( "" ) ;
104+ logger . Error ( e , $ "fail to log exception in program logger, parts length is too small: { parts . Length } , message: { message } ") ;
105+ }
106+
107+ var classname = parts [ 1 ] ;
108+ var callingMethodName = parts [ 2 ] ;
109+ var loadingProgramPath = parts [ 3 ] ;
110+ var interpretationMessage = parts [ 4 ] ;
111+
112+ LogException ( classname , callingMethodName , loadingProgramPath , interpretationMessage , e ) ;
113+ }
114+
100115 private static bool IsKnownWinProgramError ( Exception e , string callingMethodName )
101116 {
102117 if ( e . TargetSite ? . Name == "GetDescription" && callingMethodName == "LnkProgram" )
0 commit comments