# HG changeset patch # User Rik # Date 1371579057 25200 # Node ID 2b86cb4e172b6db6c01831ca983b7bd088d7017b # Parent 1c68c76c80c81917ec98e71576ea2317bbc944b7 doc: clarify docstring regarding null input to error() (bug #39271). * libinterp/interpfcn/error.cc(error): clarify docstring regarding null input to error() (bug #39271). diff --git a/libinterp/interpfcn/error.cc b/libinterp/interpfcn/error.cc --- a/libinterp/interpfcn/error.cc +++ b/libinterp/interpfcn/error.cc @@ -1069,6 +1069,27 @@ @end group\n\ @end example\n\ \n\ +A null string (\"\") input to @code{error} will be ignored and the code\n\ +will continue running as if the statement were a NOP@. This is for\n\ +compatibility with @sc{matlab}. It also makes it possible to write code such\n\ +as\n\ +\n\ +@example\n\ +@group\n\ +err_msg = \"\";\n\ +if (CONDITION 1)\n\ + err_msg = \"CONDITION 1 found\";\n\ +elseif (CONDITION2)\n\ + err_msg = \"CONDITION 2 found\";\n\ +@dots{}\n\ +endif\n\ +error (err_msg);\n\ +@end group\n\ +@end example\n\ +\n\ +@noindent\n\ +which will only stop execution if an error has been found.\n\ +\n\ Implementation Note: For compatibility with @sc{matlab}, escape\n\ sequences (e.g., \"\\n\" => newline) are processed in @var{template}\n\ regardless of whether @var{template} has been defined within single quotes\n\