Making it clearer an exception came from ycmd

Makes debugging easier when you know where the error lies.
This commit is contained in:
Val Markovic 2016-02-28 14:38:23 -08:00
parent b04870c824
commit 1e72f4d421
2 changed files with 8 additions and 5 deletions

View File

@ -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 ):

View File

@ -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 ),
] )