소스 검색

Making it clearer an exception came from ycmd

Makes debugging easier when you know where the error lies.
Val Markovic 9 년 전
부모
커밋
1e72f4d421
2개의 변경된 파일8개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 1
      python/ycm/client/base_request.py
  2. 5 4
      python/ycm/tests/event_notification_test.py

+ 3 - 1
python/ycm/client/base_request.py

@@ -42,6 +42,8 @@ _EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 )
 _DEFAULT_TIMEOUT_SEC = 30
 _HMAC_HEADER = 'x-ycm-hmac'
 
+YCMD_ERROR_PREFIX = 'ycmd exception: '
+
 class BaseRequest( object ):
   def __init__( self ):
     pass
@@ -189,7 +191,7 @@ def HandleServerException( exception ):
   # up often and isn't something that's actionable by the user.
   if 'already being parsed' in serialized_exception:
     return
-  vimsupport.PostVimMessage( serialized_exception )
+  vimsupport.PostVimMessage( YCMD_ERROR_PREFIX + serialized_exception )
 
 
 def _ToUtf8Json( data ):

+ 5 - 4
python/ycm/tests/event_notification_test.py

@@ -30,6 +30,7 @@ import contextlib
 import os
 
 from ycm.youcompleteme import YouCompleteMe
+from ycm.client.base_request import YCMD_ERROR_PREFIX
 from ycmd import user_options_store
 from ycmd.responses import ( BuildDiagnosticData, Diagnostic, Location, Range,
                              UnknownExtraConf )
@@ -192,13 +193,13 @@ class EventNotification_test( object ):
 
         # The first call raises a warning
         vim_command.assert_has_exact_calls( [
-          PostVimMessage_Call( ERROR_TEXT ),
+          PostVimMessage_Call( YCMD_ERROR_PREFIX + ERROR_TEXT ),
         ] )
 
         # Subsequent calls don't re-raise the warning
         self.server_state.HandleFileParseRequest()
         vim_command.assert_has_exact_calls( [
-          PostVimMessage_Call( ERROR_TEXT ),
+          PostVimMessage_Call( YCMD_ERROR_PREFIX + ERROR_TEXT ),
         ] )
 
         # But it does if a subsequent event raises again
@@ -206,8 +207,8 @@ class EventNotification_test( object ):
         assert self.server_state.FileParseRequestReady()
         self.server_state.HandleFileParseRequest()
         vim_command.assert_has_exact_calls( [
-          PostVimMessage_Call( ERROR_TEXT ),
-          PostVimMessage_Call( ERROR_TEXT ),
+          PostVimMessage_Call( YCMD_ERROR_PREFIX + ERROR_TEXT ),
+          PostVimMessage_Call( YCMD_ERROR_PREFIX + ERROR_TEXT ),
         ] )