mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 01:38:16 +00:00
fix(api): make nvim_parse_cmd
propagate errors
Makes `nvim_parse_cmd` propagate any errors that occur while parsing to give the user a better idea of what's wrong with the command.
This commit is contained in:
@@ -802,10 +802,15 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
||||
// Parse command line
|
||||
exarg_T ea;
|
||||
CmdParseInfo cmdinfo;
|
||||
char_u *cmdline = (char_u *)string_to_cstr(str);
|
||||
char *cmdline = string_to_cstr(str);
|
||||
char *errormsg = NULL;
|
||||
|
||||
if (!parse_cmdline(cmdline, &ea, &cmdinfo)) {
|
||||
api_set_error(err, kErrorTypeException, "Error while parsing command line");
|
||||
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
|
||||
if (errormsg != NULL) {
|
||||
api_set_error(err, kErrorTypeException, "Error while parsing command line: %s", errormsg);
|
||||
} else {
|
||||
api_set_error(err, kErrorTypeException, "Error while parsing command line");
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user