Navigation

Operators and Keywords

Function List:

C++ API

error.cc File Reference

#include <cstdarg>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include "defun.h"
#include "error.h"
#include "input.h"
#include "pager.h"
#include "oct-obj.h"
#include "oct-map.h"
#include "utils.h"
#include "ov.h"
#include "ov-usr-fcn.h"
#include "pt-pr-code.h"
#include "pt-stmt.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "variables.h"
Include dependency graph for error.cc:

Typedefs

typedef void(* error_fun )(const char *, const char *,...)

Functions

void reset_error_handler (void)
void vmessage (const char *name, const char *fmt, va_list args)
void message (const char *name, const char *fmt,...)
void vmessage_with_id (const char *name, const char *id, const char *fmt, va_list args)
void message_with_id (const char *name, const char *id, const char *fmt,...)
void usage_1 (const char *id, const char *fmt, va_list args)
void vusage (const char *fmt, va_list args)
void usage (const char *fmt,...)
void vusage_with_id (const char *id, const char *fmt, va_list args)
void usage_with_id (const char *id, const char *fmt,...)
void verror (const char *fmt, va_list args)
void error (const char *fmt,...)
void verror_with_cfn (const char *fmt, va_list args)
void error_with_cfn (const char *fmt,...)
void verror_with_id (const char *id, const char *fmt, va_list args)
void error_with_id (const char *id, const char *fmt,...)
void verror_with_id_cfn (const char *id, const char *fmt, va_list args)
void error_with_id_cfn (const char *id, const char *fmt,...)
int warning_enabled (const std::string &id)
void vwarning (const char *fmt, va_list args)
void warning (const char *fmt,...)
void vwarning_with_id (const char *id, const char *fmt, va_list args)
void warning_with_id (const char *id, const char *fmt,...)
void vparse_error (const char *fmt, va_list args)
void parse_error (const char *fmt,...)
void vparse_error_with_id (const char *id, const char *fmt, va_list args)
void parse_error_with_id (const char *id, const char *fmt,...)
void rethrow_error (const char *id, const char *fmt,...)
void panic (const char *fmt,...)
void defun_usage_message (const std::string &msg)
octave_value_list Fsprintf (const octave_value_list &, int)
 DEFUN (rethrow, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} rethrow (@var{err})\n\ Reissue a previous error as defined by @var{err}. @var{err} is a structure\n\ that must contain at least the 'message' and 'identifier' fields. @var{err}\n\ can also contain a field 'stack' that gives information on the assumed\n\ location of the error. Typically @var{err} is returned from\n\ @code{lasterror}.\n\ @seealso{lasterror, lasterr, error}\n\ @end deftypefn")
 DEFUN (error, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\ Format the optional arguments under the control of the template string\n\ @var{template} using the same rules as the @code{printf} family of\n\ functions (@pxref{Formatted Output}) and print the resulting message\n\ on the @code{stderr} stream. The message is prefixed by the character\n\ string @samp{error: }.\n\ \n\ Calling @code{error} also sets Octave's internal error state such that\n\ control will return to the top level without evaluating any more\n\ commands. This is useful for aborting from functions or scripts.\n\ \n\ If the error message does not end with a new line character, Octave will\n\ print a traceback of all the function calls leading to the error. For\n\ example, given the following function definitions:\n\ \n\ @example\n\ @group\n\ function f () g (); end\n\ function g () h (); end\n\ function h () nargin == 1 || error (\"nargin != 1\"); end\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ calling the function @code{f} will result in a list of messages that\n\ can help you to quickly locate the exact location of the error:\n\ \n\ @example\n\ @group\n\ f ()\n\ error: nargin != 1\n\ error: called from:\n\ error: error at line -1, column -1\n\ error: h at line 1, column 27\n\ error: g at line 1, column 15\n\ error: f at line 1, column 15\n\ @end group\n\ @end example\n\ \n\ If the error message ends in a new line character, Octave will print the\n\ message but will not display any traceback messages as it returns\n\ control to the top level. For example, modifying the error message\n\ in the previous example to end in a new line causes Octave to only print\n\ a single message:\n\ \n\ @example\n\ @group\n\ function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\ f ()\n\ error: nargin != 1\n\ @end group\n\ @end example\n\ @end deftypefn")
 DEFUN (warning, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ Format the optional arguments under the control of the template string\n\ @var{template} using the same rules as the @code{printf} family of\n\ functions (@pxref{Formatted Output}) and print the resulting message\n\ on the @code{stderr} stream. The message is prefixed by the character\n\ string @samp{warning: }.\n\ You should use this function when you want to notify the user\n\ of an unusual condition, but only when it makes sense for your program\n\ to go on.\n\ \n\ The optional message identifier allows users to enable or disable\n\ warnings tagged by @var{id}. The special identifier @samp{\"all\"} may\n\ be used to set the state of all warnings.\n\ \n\ @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\ @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ Set or query the state of a particular warning using the identifier\n\ @var{id}. If the identifier is omitted, a value of @samp{\"all\"} is\n\ assumed. If you set the state of a warning to @samp{\"error\"}, the\n\ warning named by @var{id} is handled as if it were an error instead.\n\ @seealso{warning_ids}\n\ @end deftypefn")
octave_value_list set_warning_state (const std::string &id, const std::string &state)
octave_value_list set_warning_state (const octave_value_list &args)
void disable_warning (const std::string &id)
void initialize_default_warning_state (void)
 DEFUN (lasterror, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{lasterr} =} lasterror ()\n\ @deftypefnx {Built-in Function} {} lasterror (@var{err})\n\ @deftypefnx {Built-in Function} {} lasterror ('reset')\n\ Query or set the last error message. Called without any arguments\n\ returns a structure containing the last error message, as well as other\n\ information related to this error. The elements of this structure are:\n\ \n\ @table @asis\n\ @item 'message'\n\ The text of the last error message\n\ \n\ @item 'identifier'\n\ The message identifier of this error message\n\ \n\ @item 'stack'\n\ A structure containing information on where the message occurred. This might\n\ be an empty structure if this in the case where this information cannot\n\ be obtained. The fields of this structure are:\n\ \n\ @table @asis\n\ @item 'file'\n\ The name of the file where the error occurred\n\ \n\ @item 'name'\n\ The name of function in which the error occurred\n\ \n\ @item 'line'\n\ The line number at which the error occurred\n\ \n\ @item 'column'\n\ An optional field with the column number at which the error occurred\n\ @end table\n\ @end table\n\ \n\ The @var{err} structure may also be passed to @code{lasterror} to set the\n\ information about the last error. The only constraint on @var{err} in that\n\ case is that it is a scalar structure. Any fields of @var{err} that match\n\ the above are set to the value passed in @var{err}, while other fields are\n\ set to their default values.\n\ \n\ If @code{lasterror} is called with the argument 'reset', all values take\n\ their default values.\n\ @end deftypefn")
 DEFUN (lasterr, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr (@var{msg}, @var{msgid})\n\ Without any arguments, return the last error message. With one\n\ argument, set the last error message to @var{msg}. With two arguments,\n\ also set the last message identifier.\n\ @end deftypefn")
 DEFALIAS (error_text, lasterr)
 DEFALIAS (__error_text__, lasterr)
 DEFUN (lastwarn, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn (@var{msg}, @var{msgid})\n\ Without any arguments, return the last warning message. With one\n\ argument, set the last warning message to @var{msg}. With two arguments,\n\ also set the last message identifier.\n\ @end deftypefn")
 DEFUN (usage, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} usage (@var{msg})\n\ Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\ set Octave's internal error state such that control will return to the\n\ top level without evaluating any more commands. This is useful for\n\ aborting from functions.\n\ \n\ After @code{usage} is evaluated, Octave will print a traceback of all\n\ the function calls leading to the usage message.\n\ \n\ You should use this function for reporting problems errors that result\n\ from an improper call to a function, such as calling a function with an\n\ incorrect number of arguments, or with arguments of the wrong type. For\n\ example, most functions distributed with Octave begin with code like\n\ this\n\ \n\ @example\n\ @group\n\ if (nargin != 2)\n\ usage (\"foo (a, b)\");\n\ endif\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ to check for the proper number of arguments.\n\ @end deftypefn")
 DEFUN (beep_on_error, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\ Query or set the internal variable that controls whether Octave will try\n\ to ring the terminal bell before printing an error message.\n\ @end deftypefn")
 DEFUN (debug_on_error, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\ Query or set the internal variable that controls whether Octave will try\n\ to enter the debugger when an error is encountered. This will also\n\ inhibit printing of the normal traceback message (you will only see\n\ the top-level error message).\n\ @end deftypefn")
 DEFUN (debug_on_warning, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\ Query or set the internal variable that controls whether Octave will try\n\ to enter the debugger when a warning is encountered.\n\ @end deftypefn")
std::string last_error_message (void)
std::string last_error_id (void)
std::string last_warning_message (void)
std::string last_warning_id (void)
void interpreter_try (unwind_protect &frame)

Variables

bool Vdebug_on_error = false
bool Vdebug_on_warning = false
int error_state = 0
int warning_state = 0
int buffer_error_messages = 0
bool discard_error_messages = false
bool discard_warning_messages = false

Typedef Documentation

typedef void(* error_fun)(const char *, const char *,...)

Function Documentation

DEFALIAS ( error_text  ,
lasterr   
)
DEFALIAS ( __error_text__  ,
lasterr   
)
DEFUN ( rethrow  ,
args   
)
DEFUN ( error  ,
args   
)
DEFUN ( warning  ,
args  ,
nargout   
)
DEFUN ( lasterror  ,
args   
)
DEFUN ( debug_on_error  ,
args  ,
nargout   
)
DEFUN ( lasterr  ,
args  ,
nargout   
)
DEFUN ( lastwarn  ,
args  ,
nargout   
)
DEFUN ( usage  ,
args   
)
DEFUN ( beep_on_error  ,
args  ,
nargout   
)
DEFUN ( debug_on_warning  ,
args  ,
nargout   
)
void defun_usage_message ( const std::string &  msg  ) 
void disable_warning ( const std::string &  id  ) 
void error ( const char *  fmt,
  ... 
)
void error_with_cfn ( const char *  fmt,
  ... 
)
void error_with_id ( const char *  id,
const char *  fmt,
  ... 
)
void error_with_id_cfn ( const char *  id,
const char *  fmt,
  ... 
)
octave_value_list Fsprintf ( const octave_value_list ,
int   
)
void initialize_default_warning_state ( void   ) 
void interpreter_try ( unwind_protect frame  ) 
std::string last_error_id ( void   ) 
std::string last_error_message ( void   ) 
std::string last_warning_id ( void   ) 
std::string last_warning_message ( void   ) 
void message ( const char *  name,
const char *  fmt,
  ... 
)
void message_with_id ( const char *  name,
const char *  id,
const char *  fmt,
  ... 
)
void panic ( const char *  fmt,
  ... 
)
void parse_error ( const char *  fmt,
  ... 
)
void parse_error_with_id ( const char *  id,
const char *  fmt,
  ... 
)
void reset_error_handler ( void   ) 
void rethrow_error ( const char *  id,
const char *  fmt,
  ... 
)
octave_value_list set_warning_state ( const octave_value_list args  ) 
octave_value_list set_warning_state ( const std::string &  id,
const std::string &  state 
)
void usage ( const char *  fmt,
  ... 
)
void usage_1 ( const char *  id,
const char *  fmt,
va_list  args 
)
void usage_with_id ( const char *  id,
const char *  fmt,
  ... 
)
void verror ( const char *  fmt,
va_list  args 
)
void verror_with_cfn ( const char *  fmt,
va_list  args 
)
void verror_with_id ( const char *  id,
const char *  fmt,
va_list  args 
)
void verror_with_id_cfn ( const char *  id,
const char *  fmt,
va_list  args 
)
void vmessage ( const char *  name,
const char *  fmt,
va_list  args 
)
void vmessage_with_id ( const char *  name,
const char *  id,
const char *  fmt,
va_list  args 
)
void vparse_error ( const char *  fmt,
va_list  args 
)
void vparse_error_with_id ( const char *  id,
const char *  fmt,
va_list  args 
)
void vusage ( const char *  fmt,
va_list  args 
)
void vusage_with_id ( const char *  id,
const char *  fmt,
va_list  args 
)
void vwarning ( const char *  fmt,
va_list  args 
)
void vwarning_with_id ( const char *  id,
const char *  fmt,
va_list  args 
)
void warning ( const char *  fmt,
  ... 
)
int warning_enabled ( const std::string &  id  ) 
void warning_with_id ( const char *  id,
const char *  fmt,
  ... 
)

Variable Documentation

int error_state = 0
int warning_state = 0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines