mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
checkhealth: always report stderr with errors (#8783)
This also reports the exit code (e.g. 127 for when pyenv-which fails).
This commit is contained in:
parent
ade88fe4cc
commit
a4494b7cbc
@ -37,7 +37,12 @@ endfunction
|
|||||||
|
|
||||||
" Handler for s:system() function.
|
" Handler for s:system() function.
|
||||||
function! s:system_handler(jobid, data, event) dict abort
|
function! s:system_handler(jobid, data, event) dict abort
|
||||||
if a:event ==# 'stdout' || a:event ==# 'stderr'
|
if a:event ==# 'stderr'
|
||||||
|
let self.stderr .= join(a:data, '')
|
||||||
|
if !self.ignore_stderr
|
||||||
|
let self.output .= join(a:data, '')
|
||||||
|
endif
|
||||||
|
elseif a:event ==# 'stdout'
|
||||||
let self.output .= join(a:data, '')
|
let self.output .= join(a:data, '')
|
||||||
elseif a:event ==# 'exit'
|
elseif a:event ==# 'exit'
|
||||||
let s:shell_error = a:data
|
let s:shell_error = a:data
|
||||||
@ -57,16 +62,15 @@ endfunction
|
|||||||
" Run a system command and timeout after 30 seconds.
|
" Run a system command and timeout after 30 seconds.
|
||||||
function! s:system(cmd, ...) abort
|
function! s:system(cmd, ...) abort
|
||||||
let stdin = a:0 ? a:1 : ''
|
let stdin = a:0 ? a:1 : ''
|
||||||
let ignore_stderr = a:0 > 1 ? a:2 : 0
|
|
||||||
let ignore_error = a:0 > 2 ? a:3 : 0
|
let ignore_error = a:0 > 2 ? a:3 : 0
|
||||||
let opts = {
|
let opts = {
|
||||||
|
\ 'ignore_stderr': a:0 > 1 ? a:2 : 0,
|
||||||
\ 'output': '',
|
\ 'output': '',
|
||||||
|
\ 'stderr': '',
|
||||||
\ 'on_stdout': function('s:system_handler'),
|
\ 'on_stdout': function('s:system_handler'),
|
||||||
|
\ 'on_stderr': function('s:system_handler'),
|
||||||
\ 'on_exit': function('s:system_handler'),
|
\ 'on_exit': function('s:system_handler'),
|
||||||
\ }
|
\ }
|
||||||
if !ignore_stderr
|
|
||||||
let opts.on_stderr = function('s:system_handler')
|
|
||||||
endif
|
|
||||||
let jobid = jobstart(a:cmd, opts)
|
let jobid = jobstart(a:cmd, opts)
|
||||||
|
|
||||||
if jobid < 1
|
if jobid < 1
|
||||||
@ -85,8 +89,8 @@ function! s:system(cmd, ...) abort
|
|||||||
call health#report_error(printf('Command timed out: %s', s:shellify(a:cmd)))
|
call health#report_error(printf('Command timed out: %s', s:shellify(a:cmd)))
|
||||||
call jobstop(jobid)
|
call jobstop(jobid)
|
||||||
elseif s:shell_error != 0 && !ignore_error
|
elseif s:shell_error != 0 && !ignore_error
|
||||||
call health#report_error(printf("Command error (job=%d): `%s` (in %s)\nOutput: %s",
|
call health#report_error(printf("Command error (job=%d, exit code %d): `%s` (in %s)\nOutput: %s\nStderr: %s",
|
||||||
\ jobid, s:shellify(a:cmd), string(getcwd()), opts.output))
|
\ jobid, s:shell_error, s:shellify(a:cmd), string(getcwd()), opts.output, opts.stderr))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return opts.output
|
return opts.output
|
||||||
|
Loading…
Reference in New Issue
Block a user