octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #45967] More consistent error message style fo


From: Rik
Subject: [Octave-bug-tracker] [bug #45967] More consistent error message style for parse errors
Date: Wed, 17 Jan 2024 20:18:07 -0500 (EST)

Follow-up Comment #7, bug#45967 (group octave):

@jwe: I'm having trouble getting the program stack to be reported for parse
errors.  The chain begins in oct-parse.yy which calls parse_error_with_id(). 
The action then shifts to error.cc.  The function parse_error_with_id() calls
vparse_error_with_id() which calls error_1().  


void
error_system::error_1 (const char *id, const char *fmt,
                       va_list args)
{
  std::string message = format_message (fmt, args);

  std::list<frame_info> stack_info;

  throw_error ("error", id, message);
}


The creation of the stack_info variable is unnecessary.  I'm not sure why the
compiler doesn't throw a warning since it is unused.  In any case, this
eventually calls throw_error().


void
error_system::throw_error (const std::string& err_type,
                           const std::string& id,
                           const std::string& message,
                           const std::list<frame_info>& stack_info_arg)
{
  std::list<frame_info> stack_info = stack_info_arg;

  if (stack_info.empty ())
    {
      tree_evaluator& tw = m_interpreter.get_evaluator ();

      stack_info = tw.backtrace_info ();

      // Print the error message only if it is different from the
      // previous one; makes the output more concise and readable.

      stack_info.unique ();
    }

  execution_exception ex (err_type, id, message, stack_info);

  throw_error (ex);
}


Since throw_error() is called without any stack_info the function calls
tw.backtrace_info(), but this returns an empty stack.  Do you know why that
would be?  Does parsing have to complete before the stack tree is populated?

If so, I can arrange for parser_error to call one of the other forms of
error() and provide a stack to be printed.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?45967>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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