Merge pull request #1720 from MTDL9/fix-error-response-string-data

Fix E712 error in ale#lsp#response#GetErrorMessage when receiving string primitives in the error.data field
This commit is contained in:
w0rp 2018-07-13 09:30:54 +01:00 committed by w0rp
parent 7d66293bbc
commit 033a6c1178
No known key found for this signature in database
GPG key ID: 0FC1ECAA8C81CD83
2 changed files with 19 additions and 4 deletions

View file

@ -105,11 +105,17 @@ function! ale#lsp#response#GetErrorMessage(response) abort
return ''
endif
" Include the traceback as details, if it's there.
let l:traceback = get(get(a:response.error, 'data', {}), 'traceback', [])
" Include the traceback or error data as details, if present.
let l:error_data = get(a:response.error, 'data', {})
if type(l:traceback) is type([]) && !empty(l:traceback)
let l:message .= "\n" . join(l:traceback, "\n")
if type(l:error_data) is type('')
let l:message .= "\n" . l:error_data
else
let l:traceback = get(l:error_data, 'traceback', [])
if type(l:traceback) is type([]) && !empty(l:traceback)
let l:message .= "\n" . join(l:traceback, "\n")
endif
endif
return l:message

View file

@ -63,3 +63,12 @@ Execute(Messages with tracebacks should be handled):
\ },
\ },
\})
Execute(Messages with string data should be handled):
AssertEqual "xyz\nUncaught Exception", ale#lsp#response#GetErrorMessage({
\ 'error': {
\ 'code': -32602,
\ 'message': 'xyz',
\ 'data': 'Uncaught Exception',
\ },
\})