Merge pull request #547 from blueyed/improve-error-on-init

Improve error messages during init
This commit is contained in:
Dave Halter
2016-03-20 04:34:08 +01:00
3 changed files with 18 additions and 20 deletions

View File

@@ -126,12 +126,11 @@ function! jedi#init_python()
try try
let s:_init_python = s:init_python() let s:_init_python = s:init_python()
catch catch
if !exists("g:jedi#squelch_py_warning")
echohl WarningMsg
echom "Error: jedi-vim failed to initialize Python: ".v:exception." (in ".v:throwpoint.")"
echohl None
endif
let s:_init_python = 0 let s:_init_python = 0
if !exists("g:jedi#squelch_py_warning")
echoerr "Error: jedi-vim failed to initialize Python: "
\ .v:exception." (in ".v:throwpoint.")"
endif
endtry endtry
endif endif
return s:_init_python return s:_init_python
@@ -154,11 +153,11 @@ function! jedi#setup_py_version(py_version)
try try
execute cmd_init.' '.s:script_path.'/initialize.py' execute cmd_init.' '.s:script_path.'/initialize.py'
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
return 1
catch catch
throw "jedi#setup_py_version: ".v:exception throw "jedi#setup_py_version: ".v:exception
endtry endtry
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
return 1
endfunction endfunction
@@ -202,12 +201,7 @@ function! jedi#_vim_exceptions(str, is_eval)
return l:result return l:result
endfunction endfunction
call jedi#init_python() " Might throw an error.
if !jedi#init_python()
" Do not define any functions when Python initialization failed.
finish
endif
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
" functions that call python code " functions that call python code

View File

@@ -18,5 +18,10 @@ import traceback
# update the sys path to include the jedi_vim script # update the sys path to include the jedi_vim script
sys.path.insert(0, vim.eval('expand(s:script_path)')) sys.path.insert(0, vim.eval('expand(s:script_path)'))
try:
import jedi_vim import jedi_vim
except Exception as excinfo:
raise Exception('Failed to import jedi_vim: {0}\n{1}'.format(
excinfo, traceback.format_exc()))
finally:
sys.path.pop(1) sys.path.pop(1)

View File

@@ -78,12 +78,11 @@ def vim_eval(string):
def no_jedi_warning(error=None): def no_jedi_warning(error=None):
msg = "Please install Jedi if you want to use jedi-vim." vim.command('echohl WarningMsg')
vim.command('echom "Please install Jedi if you want to use jedi-vim."')
if error: if error:
msg = '{0} The error was: {1}'.format(msg, error) vim.command('echom "The error was: {0}"'.format(error))
vim.command('echohl WarningMsg' vim.command('echohl None')
'| echom "Please install Jedi if you want to use jedi-vim."'
'| echohl None')
def echo_highlight(msg): def echo_highlight(msg):