comparison libinterp/corefcn/error.cc @ 20127:a42de4173533

also provide stack traces for errors in script files (bug #44862) * error.cc (error_2, warning_1): Check whether we are in user code rather than at the top-level symbol table to determine whether to display a stack trace.
author John W. Eaton <jwe@octave.org>
date Fri, 24 Apr 2015 22:31:21 -0400
parents e51473fdb622
children 0aed244dbdb3
comparison
equal deleted inserted replaced
20126:d34e31b07966 20127:a42de4173533
445 { 445 {
446 int init_state = error_state; 446 int init_state = error_state;
447 447
448 error_1 (std::cerr, "error", id, fmt, args, with_cfn); 448 error_1 (std::cerr, "error", id, fmt, args, with_cfn);
449 449
450 if (error_state != -2 && ! symbol_table::at_top_level () 450 bool in_user_code = octave_call_stack::caller_user_code () != 0;
451 && ! discard_error_messages) 451
452 if (error_state != -2 && in_user_code && ! discard_error_messages)
452 pr_where ("error"); 453 pr_where ("error");
453 454
454 if (interactive 455 if (interactive && Vdebug_on_error && init_state == 0 && in_user_code)
455 && Vdebug_on_error && init_state == 0
456 && octave_call_stack::caller_user_code ())
457 { 456 {
458 unwind_protect frame; 457 unwind_protect frame;
459 frame.protect_var (Vdebug_on_error); 458 frame.protect_var (Vdebug_on_error);
460 Vdebug_on_error = false; 459 Vdebug_on_error = false;
461 460
635 } 634 }
636 else if (warn_opt == 1) 635 else if (warn_opt == 1)
637 { 636 {
638 vwarning ("warning", id, fmt, args); 637 vwarning ("warning", id, fmt, args);
639 638
640 if (! symbol_table::at_top_level () 639 bool in_user_code = octave_call_stack::caller_user_code () != 0;
641 && Vbacktrace_on_warning 640
642 && ! warning_state 641 if (in_user_code && Vbacktrace_on_warning && ! warning_state
643 && ! discard_warning_messages) 642 && ! discard_warning_messages)
644 pr_where ("warning"); 643 pr_where ("warning");
645 644
646 warning_state = 1; 645 warning_state = 1;
647 646
648 if ((interactive || forced_interactive) 647 if ((interactive || forced_interactive)
649 && Vdebug_on_warning 648 && Vdebug_on_warning && in_user_code)
650 && octave_call_stack::caller_user_code ())
651 { 649 {
652 unwind_protect frame; 650 unwind_protect frame;
653 frame.protect_var (Vdebug_on_warning); 651 frame.protect_var (Vdebug_on_warning);
654 Vdebug_on_warning = false; 652 Vdebug_on_warning = false;
655 653