Preventing traceback for detailed diagnostic
Previously we'd show a Python traceback if the user asked for a detailed diagnostic in a file that wasn't supported by Clang (something written in Python perhaps). Now we show an nice, far less scary message informing the user of this. Fixes #748.
This commit is contained in:
parent
afb70bf65e
commit
e424d75c42
@ -27,6 +27,7 @@ else:
|
||||
from ycm_core import FilterAndSortCandidates
|
||||
|
||||
from ycm.completers.completer_utils import TriggersForFiletype
|
||||
from ycm.server.responses import NoDiagnosticSupport
|
||||
|
||||
NO_USER_COMMANDS = 'This completer does not define any commands.'
|
||||
|
||||
@ -245,11 +246,11 @@ class Completer( object ):
|
||||
|
||||
|
||||
def GetDiagnosticsForCurrentFile( self, request_data ):
|
||||
return []
|
||||
raise NoDiagnosticSupport
|
||||
|
||||
|
||||
def GetDetailedDiagnostic( self, request_data ):
|
||||
pass
|
||||
raise NoDiagnosticSupport
|
||||
|
||||
|
||||
def _CurrentFiletype( self, filetypes ):
|
||||
|
@ -28,6 +28,9 @@ NO_EXTRA_CONF_FILENAME_MESSAGE = ( 'No {0} file detected, so no compile flags '
|
||||
'are available. Thus no semantic support for C/C++/ObjC/ObjC++. Go READ THE '
|
||||
'DOCS *NOW*, DON\'T file a bug report.' ).format( YCM_EXTRA_CONF_FILENAME )
|
||||
|
||||
NO_DIAGNOSTIC_SUPPORT_MESSAGE = ( 'YCM has no diagnostics support for this '
|
||||
'filetype; refer to Syntastic docs if using Syntastic.')
|
||||
|
||||
|
||||
class ServerError( Exception ):
|
||||
def __init__( self, message ):
|
||||
@ -47,6 +50,11 @@ class NoExtraConfDetected( ServerError ):
|
||||
NO_EXTRA_CONF_FILENAME_MESSAGE )
|
||||
|
||||
|
||||
class NoDiagnosticSupport( ServerError ):
|
||||
def __init__( self ):
|
||||
super( NoDiagnosticSupport, self ).__init__( NO_DIAGNOSTIC_SUPPORT_MESSAGE )
|
||||
|
||||
|
||||
def BuildGoToResponse( filepath, line_num, column_num, description = None ):
|
||||
response = {
|
||||
'filepath': os.path.realpath( filepath ),
|
||||
|
@ -21,11 +21,13 @@ from ..server_utils import SetUpPythonPath
|
||||
SetUpPythonPath()
|
||||
from .test_utils import Setup, BuildRequest
|
||||
from webtest import TestApp
|
||||
from nose.tools import with_setup
|
||||
from nose.tools import with_setup, eq_
|
||||
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
||||
has_entry, empty )
|
||||
from ..responses import NoDiagnosticSupport
|
||||
from .. import handlers
|
||||
import bottle
|
||||
import httplib
|
||||
|
||||
bottle.debug( True )
|
||||
|
||||
@ -104,3 +106,19 @@ struct Foo {
|
||||
assert_that( results,
|
||||
has_entry( 'message', contains_string( "expected ';'" ) ) )
|
||||
|
||||
|
||||
@with_setup( Setup )
|
||||
def GetDetailedDiagnostic_JediCompleter_DoesntWork_test():
|
||||
app = TestApp( handlers.app )
|
||||
diag_data = BuildRequest( contents = "foo = 5",
|
||||
line_num = 1,
|
||||
filetype = 'python' )
|
||||
response = app.post_json( '/detailed_diagnostic',
|
||||
diag_data,
|
||||
expect_errors = True )
|
||||
|
||||
eq_( response.status_code, httplib.INTERNAL_SERVER_ERROR )
|
||||
assert_that( response.json,
|
||||
has_entry( 'exception',
|
||||
has_entry( 'TYPE', NoDiagnosticSupport.__name__ ) ) )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user