summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-07-13 09:30:54 +0100
committerGitHub <noreply@github.com>2018-07-13 09:30:54 +0100
commit6d6cd6663eefd02603d28011a5a02f1792bbcde9 (patch)
tree5fb4fa8643c4247eaaebc0e411775ffc8c9cddb4
parentd22b9bf1a694aad94a8249457045149b8fce7255 (diff)
parent021f59b3f4570cc3f2f459a3d019743c5beb8ac9 (diff)
downloadale-6d6cd6663eefd02603d28011a5a02f1792bbcde9.zip
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
-rw-r--r--autoload/ale/lsp/response.vim14
-rw-r--r--test/lsp/test_lsp_error_parsing.vader9
2 files changed, 19 insertions, 4 deletions
diff --git a/autoload/ale/lsp/response.vim b/autoload/ale/lsp/response.vim
index 94794e98..3ac65388 100644
--- a/autoload/ale/lsp/response.vim
+++ b/autoload/ale/lsp/response.vim
@@ -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
diff --git a/test/lsp/test_lsp_error_parsing.vader b/test/lsp/test_lsp_error_parsing.vader
index 7464b0e7..44169c80 100644
--- a/test/lsp/test_lsp_error_parsing.vader
+++ b/test/lsp/test_lsp_error_parsing.vader
@@ -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',
+ \ },
+ \})