octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifications to error handling for the command suggestion feature


From: Rik
Subject: Re: Modifications to error handling for the command suggestion feature
Date: Sat, 19 May 2018 20:26:22 -0700

On 05/19/2018 02:12 PM, Sudeepam Pandey wrote:


Providing a list of suggestions and then returning to the CLI is going to be easier then changing the parser--which has already gone down an error path--to accept new input, backup, and re-parse the new command.  The latter can be done, but for the moment I would concentrate on just offering the user some suggestions.

You did correctly find the code in pt-id.cc to modify.  The complete routine is

  void
  tree_identifier::eval_undefined_error (void)
  {
    int l = line ();
    int c = column ();

    maybe_missing_function_hook (name ());

    if (l == -1 && c == -1)
      error_with_id ("Octave:undefined-function",
                     "'%s' undefined", name ().c_str ());
    else
      error_with_id ("Octave:undefined-function",
                     "'%s' undefined near line %d column %d",
                     name ().c_str (), l, c);
  }

What you want to do is print out an error message first, then call maybe_missing_function_hook, and then return to the prompt.  You can't use error_with_id because it is based on exceptions and will return to the prompt as soon as it is done.  However, you can print the warning to stderr, which is what the error() function is doing anyways.  Try this

Our primary need is not to print the error message first, but to make sure that an error message for the mistake made in the last command does not occur after the user has executed the correct command. 

If the command is correct, then there is no undefined error.  If the command is not correct, you can offer a suggestion, but there is no way for the user to correct the command and have it execute.  They need to return to the prompt and enter the correct command.  That was my point about not being able to back up the parser and have it re-execute on the suggestion that you supply in the function called by missing_function_hook.

--Rik

reply via email to

[Prev in Thread] Current Thread [Next in Thread]