diff libinterp/corefcn/help.cc @ 20616:fd0efcdb3718

use new string_value method to handle value extraction errors * dirfns.cc, file-io.cc, gammainc.cc, help.cc, load-path.cc, octave-link.cc, qz.cc, regexp.cc, strfns.cc, syscalls.cc, time.cc, variables.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 19:00:51 -0400
parents a9574e3c6e9e
children
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Thu Oct 08 17:55:57 2015 -0400
+++ b/libinterp/corefcn/help.cc	Thu Oct 08 19:00:51 2015 -0400
@@ -1092,20 +1092,15 @@
 
   if (args.length () == 1)
     {
-      const std::string name = args(0).string_value ();
+      const std::string name = args(0).string_value ("get_help_text: NAME must be a string");
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+      std::string text;
+      std::string format;
 
-          do_get_help_text (name, text, format);
+      do_get_help_text (name, text, format);
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text: invalid input");
+      retval(1) = format;
+      retval(0) = text;
     }
   else
     print_usage ();
@@ -1162,20 +1157,15 @@
 
   if (args.length () == 1)
     {
-      const std::string fname = args(0).string_value ();
+      const std::string fname = args(0).string_value ("get_help_text_from_file: NAME must be a string");
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+      std::string text;
+      std::string format;
 
-          do_get_help_text_from_file (fname, text, format);
+      do_get_help_text_from_file (fname, text, format);
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text_from_file: invalid input");
+      retval(1) = format;
+      retval(0) = text;
     }
   else
     print_usage ();
@@ -1380,24 +1370,19 @@
 
   if (args.length () == 0)
     retval = Cell (ffl.append (afl));
-  else if (args(0).is_string ())
+  else
     {
-      std::string dir = args(0).string_value ();
+      std::string dir = args(0).string_value ("__list_functions__: DIRECTORY argument must be a string");
 
       string_vector fl = load_path::files (dir, true);
 
-      if (! error_state)
-        {
-          // Return a sorted list with unique entries (in case of
-          // .m and .oct versions of the same function in a given
-          // directory, for example).
-          fl.sort (true);
+      // Return a sorted list with unique entries (in case of
+      // .m and .oct versions of the same function in a given
+      // directory, for example).
+      fl.sort (true);
 
-          retval = Cell (fl);
-        }
+      retval = Cell (fl);
     }
-  else
-    error ("__list_functions__: DIRECTORY argument must be a string");
 
   return retval;
 }