Auto merge of #1632 - puremourning:general-completions-when-no-semantic, r=Valloric
If errors are returned in addition to completion suggestions, print them Needed for https://github.com/Valloric/ycmd/pull/198 This maintains the previous client behaviour when the semantic completer throws an exception.
This commit is contained in:
commit
33621d409b
@ -163,7 +163,7 @@ def JsonFromFuture( future ):
|
||||
response = future.result()
|
||||
_ValidateResponseObject( response )
|
||||
if response.status_code == requests.codes.server_error:
|
||||
_RaiseExceptionForData( response.json() )
|
||||
raise MakeServerException( response.json() )
|
||||
|
||||
# We let Requests handle the other status types, we only handle the 500
|
||||
# error code.
|
||||
@ -218,10 +218,9 @@ def _CheckServerIsHealthyWithCache():
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def _RaiseExceptionForData( data ):
|
||||
def MakeServerException( data ):
|
||||
if data[ 'exception' ][ 'TYPE' ] == UnknownExtraConf.__name__:
|
||||
raise UnknownExtraConf( data[ 'exception' ][ 'extra_conf_file' ] )
|
||||
return UnknownExtraConf( data[ 'exception' ][ 'extra_conf_file' ] )
|
||||
|
||||
raise ServerError( '{0}: {1}'.format( data[ 'exception' ][ 'TYPE' ],
|
||||
return ServerError( '{0}: {1}'.format( data[ 'exception' ][ 'TYPE' ],
|
||||
data[ 'message' ] ) )
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
from ycmd.utils import ToUtf8IfNeeded
|
||||
from ycm.client.base_request import ( BaseRequest, JsonFromFuture,
|
||||
HandleServerException )
|
||||
HandleServerException,
|
||||
MakeServerException )
|
||||
|
||||
TIMEOUT_SECONDS = 0.5
|
||||
|
||||
@ -43,10 +44,16 @@ class CompletionRequest( BaseRequest ):
|
||||
if not self._response_future:
|
||||
return []
|
||||
try:
|
||||
return _ConvertCompletionResponseToVimDatas(
|
||||
JsonFromFuture( self._response_future ) )
|
||||
response = JsonFromFuture( self._response_future )
|
||||
|
||||
errors = response['errors'] if 'errors' in response else []
|
||||
for e in errors:
|
||||
HandleServerException( MakeServerException( e ) )
|
||||
|
||||
return _ConvertCompletionResponseToVimDatas( response )
|
||||
except Exception as e:
|
||||
HandleServerException( e )
|
||||
|
||||
return []
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user