Prospector: saner handling of errors.

This commit is contained in:
LCD 47 2014-10-24 19:53:39 +03:00
parent 83971066a1
commit 8e9ece2144

View File

@ -77,13 +77,20 @@ function! syntastic#preprocess#perl(errors) " {{{2
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#prospector(errors) " {{{2 function! syntastic#preprocess#prospector(errors) " {{{2
" JSON artifacts
let true = 1 let true = 1
let false = 0 let false = 0
let null = '' let null = ''
let errs = eval(join(a:errors, ''))
" A hat tip to Marc Weber for this trick
" http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
try
let errs = eval(join(a:errors, ''))
catch
let errs = {}
endtry
let out = [] let out = []
let warn_issued = 0
if type(errs) == type({}) && has_key(errs, 'messages') && type(errs['messages']) == type([]) if type(errs) == type({}) && has_key(errs, 'messages') && type(errs['messages']) == type([])
for e in errs['messages'] for e in errs['messages']
if type(e) == type({}) if type(e) == type({})
@ -99,15 +106,21 @@ function! syntastic#preprocess#prospector(errors) " {{{2
\ e['code'] . ' ' . \ e['code'] . ' ' .
\ e['message'] . ' ' . \ e['message'] . ' ' .
\ '[' . e['source'] . ']' \ '[' . e['source'] . ']'
call add(out, msg) call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/ catch /\m^Vim\%((\a\+)\)\=:E716/
if !warn_issued call syntastic#log#warn('checker python/prospector: unknown error format')
call add(out, '.:0:0: unknown error format') let out = []
let warn_issued = 1 break
endif
endtry endtry
else
call syntastic#log#warn('checker python/prospector: unknown error format')
let out = []
break
endif endif
endfor endfor
else
call syntastic#log#warn('checker python/prospector: unknown error format')
endif endif
return out return out