diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index 28dc1278..bdfe5b42 100644 --- a/python/ycm/client/command_request.py +++ b/python/ycm/client/command_request.py @@ -24,7 +24,10 @@ standard_library.install_aliases() from builtins import * # noqa import vim -from ycm.client.base_request import BaseRequest, BuildRequestData, ServerError +from ycmd.responses import ServerError +from ycm.client.base_request import ( BaseRequest, BuildRequestData, + HandleServerException ) + from ycm import vimsupport from ycmd.utils import ToUnicode @@ -54,7 +57,7 @@ class CommandRequest( BaseRequest ): self._response = self.PostDataToHandler( request_data, 'run_completer_command' ) except ServerError as e: - vimsupport.PostMultiLineNotice( e ) + HandleServerException( e ) def Response( self ): diff --git a/python/ycm/client/completer_available_request.py b/python/ycm/client/completer_available_request.py index a90ef1cb..9e98da0e 100644 --- a/python/ycm/client/completer_available_request.py +++ b/python/ycm/client/completer_available_request.py @@ -25,6 +25,7 @@ from builtins import * # noqa from ycm.client.base_request import ( BaseRequest, BuildRequestData, HandleServerException ) +from ycmd.responses import ServerError class CompleterAvailableRequest( BaseRequest ): def __init__( self, filetypes ): @@ -39,7 +40,7 @@ class CompleterAvailableRequest( BaseRequest ): try: self._response = self.PostDataToHandler( request_data, 'semantic_completion_available' ) - except Exception as e: + except ServerError as e: HandleServerException( e ) diff --git a/python/ycm/client/completion_request.py b/python/ycm/client/completion_request.py index 5b66ef3e..faf3c188 100644 --- a/python/ycm/client/completion_request.py +++ b/python/ycm/client/completion_request.py @@ -27,6 +27,7 @@ from ycmd.utils import ToUnicode from ycm.client.base_request import ( BaseRequest, JsonFromFuture, HandleServerException, MakeServerException ) +from ycmd.responses import ServerError TIMEOUT_SECONDS = 0.5 @@ -53,12 +54,12 @@ class CompletionRequest( BaseRequest ): try: response = JsonFromFuture( self._response_future ) - errors = response['errors'] if 'errors' in response else [] + errors = response[ 'errors' ] if 'errors' in response else [] for e in errors: HandleServerException( MakeServerException( e ) ) return JsonFromFuture( self._response_future )[ 'completions' ] - except Exception as e: + except ServerError as e: HandleServerException( e ) return [] diff --git a/python/ycm/client/event_notification.py b/python/ycm/client/event_notification.py index 77e05a87..5537f5b8 100644 --- a/python/ycm/client/event_notification.py +++ b/python/ycm/client/event_notification.py @@ -24,7 +24,7 @@ standard_library.install_aliases() from builtins import * # noqa from ycm import vimsupport -from ycmd.responses import UnknownExtraConf +from ycmd.responses import UnknownExtraConf, ServerError from ycm.client.base_request import ( BaseRequest, BuildRequestData, JsonFromFuture, HandleServerException ) @@ -66,7 +66,7 @@ class EventNotification( BaseRequest ): _LoadExtraConfFile( e.extra_conf_file ) else: _IgnoreExtraConfFile( e.extra_conf_file ) - except Exception as e: + except ServerError as e: HandleServerException( e ) return self._cached_response if self._cached_response else [] diff --git a/python/ycm/omni_completer.py b/python/ycm/omni_completer.py index e9703311..38da2ede 100644 --- a/python/ycm/omni_completer.py +++ b/python/ycm/omni_completer.py @@ -25,8 +25,9 @@ from builtins import * # noqa import vim from ycm import vimsupport +from ycmd.responses import ServerError from ycmd.completers.completer import Completer -from ycm.client.base_request import BaseRequest, ServerError +from ycm.client.base_request import BaseRequest, HandleServerException OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!' OMNIFUNC_NOT_LIST = ( 'Omnifunc did not return a list or a dict with a "words" ' @@ -114,5 +115,5 @@ class OmniCompleter( Completer ): return BaseRequest.PostDataToHandler( request_data, 'filter_and_sort_candidates' ) except ServerError as e: - vimsupport.PostMultiLineNotice( e ) + HandleServerException( e ) return candidates diff --git a/python/ycm/tests/event_notification_test.py b/python/ycm/tests/event_notification_test.py index 2bebd069..741f7124 100644 --- a/python/ycm/tests/event_notification_test.py +++ b/python/ycm/tests/event_notification_test.py @@ -33,7 +33,7 @@ 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 ) + UnknownExtraConf, ServerError ) from mock import call, MagicMock, patch from nose.tools import eq_, ok_ @@ -183,7 +183,7 @@ class EventNotification_test( object ): ERROR_TEXT = 'Some completer response text' def ErrorResponse( *args ): - raise RuntimeError( ERROR_TEXT ) + raise ServerError( ERROR_TEXT ) with MockArbitraryBuffer( 'javascript' ): with MockEventNotification( ErrorResponse ):