Core: better error handling for system().

This commit is contained in:
LCD 47 2016-11-21 13:55:28 +02:00
parent f3a5344f08
commit e37dca1b48
2 changed files with 19 additions and 8 deletions

View File

@ -37,8 +37,19 @@ function! syntastic#util#system(command) abort " {{{2
let $LC_MESSAGES = 'C'
let $LC_ALL = ''
let crashed = 0
let cmd_start = reltime()
let out = system(a:command)
try
let out = system(a:command)
catch
let crashed = 1
call syntastic#log#error('exception running system(' . string(a:command) . '): ' . v:exception)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '$TERM = ' . string($TERM))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '$PATH = ' . string($PATH))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
let out = ''
endtry
let cmd_time = split(reltimestr(reltime(cmd_start)))[0]
let $LC_ALL = old_lc_all
@ -46,7 +57,7 @@ function! syntastic#util#system(command) abort " {{{2
let &shell = old_shell
if exists('g:_SYNTASTIC_DEBUG_TRACE')
if !crashed && exists('g:_SYNTASTIC_DEBUG_TRACE')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'system: command run in ' . cmd_time . 's')
endif

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.8.0-5'
let g:_SYNTASTIC_VERSION = '3.8.0-6'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -126,7 +126,7 @@ endif
" Debug {{{1
let s:_DEBUG_DUMP_OPTIONS = [
let g:_SYNTASTIC_SHELL_OPTIONS = [
\ 'shell',
\ 'shellcmdflag',
\ 'shellpipe',
@ -142,10 +142,10 @@ for s:feature in [
\ ]
if exists('+' . s:feature)
call add(s:_DEBUG_DUMP_OPTIONS, s:feature)
call add(g:_SYNTASTIC_SHELL_OPTIONS, s:feature)
endif
endfor
lockvar! s:_DEBUG_DUMP_OPTIONS
lockvar! g:_SYNTASTIC_SHELL_OPTIONS
" debug constants
let g:_SYNTASTIC_DEBUG_TRACE = 1
@ -231,7 +231,7 @@ function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(a:000)
call s:_explain_skip(a:000)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
endfunction " }}}2
@ -382,7 +382,7 @@ endfunction " }}}2
"refresh and redraw all the error info for this buf when saving or reading
function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{2
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'version')
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'UpdateErrors' . (a:auto_invoked ? ' (auto)' : '') .
\ ': ' . (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))