@@ -30,7 +30,7 @@ cpdef str GetModuleDirectory():
3030
3131g_GetAppPath_dir = None
3232
33- cpdef GetAppPath(file = None ):
33+ cpdef str GetAppPath(file = None ):
3434 """ Get application path."""
3535 # On Windows after downloading file and calling Browser.GoForward(),
3636 # current working directory is set to %UserProfile%.
@@ -58,12 +58,16 @@ cpdef GetAppPath(file=None):
5858 return str (file )
5959
6060
61- cpdef ExceptHook(excType, excValue, traceObject):
61+ cpdef py_void ExceptHook(excType, excValue, traceObject):
6262 """ Global except hook to exit app cleanly on error."""
6363 # This hook does the following: in case of exception write it to
6464 # the "error.log" file, display it to the console, shutdown CEF
6565 # and exit application immediately by ignoring "finally" (_exit()).
66- errorMsg = " \n " .join(traceback.format_exception(excType, excValue,
66+ print (" [CEF Python] ExceptHook: catched exception, will shutdown CEF now" )
67+ QuitMessageLoop()
68+ Shutdown()
69+ print (" [CEF Python] ExceptHook: see the catched exception below:" )
70+ errorMsg = " " .join(traceback.format_exception(excType, excValue,
6771 traceObject))
6872 errorFile = GetAppPath(" error.log" )
6973 try :
@@ -77,16 +81,13 @@ cpdef ExceptHook(excType, excValue, traceObject):
7781 fp.write(" \n [%s ] %s \n " % (
7882 time.strftime(" %Y -%m -%d %H :%M :%S " ), errorMsg))
7983 except :
80- print (" [pygtk_.py]: WARNING: failed writing to error file: %s " % (
84+ print (" [CEF Python] WARNING: failed writing to error file: %s " % (
8185 errorFile))
8286 # Convert error message to ascii before printing, otherwise
8387 # you may get error like this:
8488 # | UnicodeEncodeError: 'charmap' codec can't encode characters
8589 errorMsg = errorMsg.encode(" ascii" , errors = " replace" )
8690 errorMsg = errorMsg.decode(" ascii" , errors = " replace" )
87- print (" \n " + errorMsg+ " \n " )
88- QuitMessageLoop()
89- Shutdown()
91+ print (" \n " + errorMsg)
9092 # noinspection PyProtectedMember
9193 os._exit(1 )
92-
0 commit comments