changeset 20682:18f38ed43962

vector_value exctractors with error messages * ov.h, ov.cc (octave_value::vector_value, octave_value::complex_vector_value, octave_value::float_vector_value, octave_value::float_complex_vector_value, octave_value::int_vector_value): New overloaded methods with error messages. * daspk.cc, dasrt.cc, dassl.cc, file-io.cc, filter.cc, graphics.cc, lsode.cc, matrix_type.cc, quad.cc rand.cc, __eigs__.cc, __magick_read__.cc: Use them and eliminate more uses of error_state.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Nov 2015 16:52:49 -0500
parents b0b37f0d7e6d
children e4593adad5cc
files libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/file-io.cc libinterp/corefcn/filter.cc libinterp/corefcn/graphics.cc libinterp/corefcn/lsode.cc libinterp/corefcn/matrix_type.cc libinterp/corefcn/quad.cc libinterp/corefcn/rand.cc libinterp/dldfcn/__eigs__.cc libinterp/dldfcn/__magick_read__.cc libinterp/octave-value/ov.cc libinterp/octave-value/ov.h
diffstat 14 files changed, 501 insertions(+), 488 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/daspk.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/daspk.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -90,7 +90,7 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
           if (tlen > 1)
             ires = tmp(1).int_value ();
@@ -393,32 +393,20 @@
             }
         }
 
-      if (error_state || ! daspk_fcn)
+      if (! daspk_fcn)
         DASPK_ABORT ();
 
-      ColumnVector state = ColumnVector (args(1).vector_value ());
-
-      if (error_state)
-        DASPK_ABORT1 ("expecting state vector as second argument");
-
-      ColumnVector deriv (args(2).vector_value ());
+      ColumnVector state = args(1).vector_value ("expecting state vector as second argument");
 
-      if (error_state)
-        DASPK_ABORT1 ("expecting derivative vector as third argument");
+      ColumnVector deriv = args(2).vector_value ("expecting derivative vector as third argument");
 
-      ColumnVector out_times (args(3).vector_value ());
-
-      if (error_state)
-        DASPK_ABORT1 ("expecting output time vector as fourth argument");
+      ColumnVector out_times = args(3).vector_value ("expecting output time vector as fourth argument");
 
       ColumnVector crit_times;
       int crit_times_set = 0;
       if (nargin > 4)
         {
-          crit_times = ColumnVector (args(4).vector_value ());
-
-          if (error_state)
-            DASPK_ABORT1 ("expecting critical time vector as fifth argument");
+          crit_times = args(4).vector_value ("expecting critical time vector as fifth argument");
 
           crit_times_set = 1;
         }
--- a/libinterp/corefcn/dasrt.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/dasrt.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -89,9 +89,9 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ("dasrt: evaluation of user-supplied function failed");
 
-          if (error_state || retval.numel () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -129,9 +129,9 @@
               warned_cf_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ("dasrt: evaluation of user-supplied function failed");
 
-          if (error_state || retval.numel () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -477,7 +477,7 @@
         }
     }
 
-  if (error_state || (! dasrt_f))
+  if (! dasrt_f)
     DASRT_ABORT;
 
   DAERTFunc func (dasrt_user_f);
@@ -506,21 +506,13 @@
       func.set_constraint_function (dasrt_user_cf);
     }
 
-  ColumnVector state (args(argp++).vector_value ());
-
-  if (error_state)
-    DASRT_ABORT2 ("expecting state vector as argument %d", argp);
-
-  ColumnVector stateprime (args(argp++).vector_value ());
+  ColumnVector state = args(argp).vector_value ("expecting state vector as argument %d", ++argp);
 
-  if (error_state)
-    DASRT_ABORT2 ("expecting time derivative of state vector as argument %d",
-                  argp);
+  ColumnVector stateprime = args(argp).vector_value ("expecting time derivative of state vector as argument %d", argp);
+  argp++;
 
-  ColumnVector out_times (args(argp++).vector_value ());
-
-  if (error_state)
-    DASRT_ABORT2 ("expecting output time vector as %s argument %d", argp);
+  ColumnVector out_times = args(argp).vector_value ("expecting output time vector as %s argument %d", argp);
+  argp++;
 
   double tzero = out_times (0);
 
@@ -530,10 +522,8 @@
 
   if (argp < nargin)
     {
-      crit_times = ColumnVector (args(argp++).vector_value ());
-
-      if (error_state)
-        DASRT_ABORT2 ("expecting critical time vector as argument %d", argp);
+      crit_times = args(argp).vector_value ("expecting critical time vector as argument %d", argp);
+      argp++;
 
       crit_times_set = true;
     }
--- a/libinterp/corefcn/dassl.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/dassl.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -90,12 +90,12 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (error_state || retval.numel () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -141,7 +141,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.numel () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -394,32 +394,20 @@
             }
         }
 
-      if (error_state || ! dassl_fcn)
+      if (! dassl_fcn)
         DASSL_ABORT ();
 
-      ColumnVector state = ColumnVector (args(1).vector_value ());
-
-      if (error_state)
-        DASSL_ABORT1 ("expecting state vector as second argument");
-
-      ColumnVector deriv (args(2).vector_value ());
+      ColumnVector state = args(1).vector_value ("expecting state vector as second argument");
 
-      if (error_state)
-        DASSL_ABORT1 ("expecting derivative vector as third argument");
+      ColumnVector deriv = args(2).vector_value ("expecting derivative vector as third argument");
 
-      ColumnVector out_times (args(3).vector_value ());
-
-      if (error_state)
-        DASSL_ABORT1 ("expecting output time vector as fourth argument");
+      ColumnVector out_times = args(3).vector_value ("expecting output time vector as fourth argument");
 
       ColumnVector crit_times;
       int crit_times_set = 0;
       if (nargin > 4)
         {
-          crit_times = ColumnVector (args(4).vector_value ());
-
-          if (error_state)
-            DASSL_ABORT1 ("expecting critical time vector as fifth argument");
+          crit_times = args(4).vector_value ("expecting critical time vector as fifth argument");
 
           crit_times_set = 1;
         }
--- a/libinterp/corefcn/file-io.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/file-io.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -1321,41 +1321,36 @@
 
   count = -1;
 
-  Array<double> size = size_arg.vector_value ();
+  Array<double> size = size_arg.vector_value ("fread: invalid SIZE specified");
+
+  std::string prec = prec_arg.string_value ("fread: PRECISION must be a string");
+
+  int block_size = 1;
+  oct_data_conv::data_type input_type;
+  oct_data_conv::data_type output_type;
+
+  oct_data_conv::string_to_data_type (prec, block_size,
+                                      input_type, output_type);
 
   if (! error_state)
     {
-      std::string prec = prec_arg.string_value ("fread: PRECISION must be a string");
-
-      int block_size = 1;
-      oct_data_conv::data_type input_type;
-      oct_data_conv::data_type output_type;
-
-      oct_data_conv::string_to_data_type (prec, block_size,
-                                          input_type, output_type);
+      int skip = skip_arg.int_value (true);
 
       if (! error_state)
         {
-          int skip = skip_arg.int_value (true);
-
-          if (! error_state)
-            {
-              std::string arch = arch_arg.string_value ("fread: ARCH architecture type must be a string");
+          std::string arch = arch_arg.string_value ("fread: ARCH architecture type must be a string");
 
-              oct_mach_info::float_format flt_fmt
-                = oct_mach_info::string_to_float_format (arch);
+          oct_mach_info::float_format flt_fmt
+            = oct_mach_info::string_to_float_format (arch);
 
-              retval = os.read (size, block_size, input_type,
-                                output_type, skip, flt_fmt, count);
-            }
-          else
-            error ("fread: SKIP must be an integer");
+          retval = os.read (size, block_size, input_type,
+                            output_type, skip, flt_fmt, count);
         }
       else
-        error ("fread: invalid PRECISION specified");
+        error ("fread: SKIP must be an integer");
     }
   else
-    error ("fread: invalid SIZE specified");
+    error ("fread: invalid PRECISION specified");
 
   return retval;
 }
--- a/libinterp/corefcn/filter.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/filter.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -440,96 +440,86 @@
     {
       if (isfloat)
         {
-          FloatComplexColumnVector b (args(0).float_complex_vector_value ());
-          FloatComplexColumnVector a (args(1).float_complex_vector_value ());
+          FloatComplexColumnVector b (args(0).float_complex_vector_value (errmsg));
+          FloatComplexColumnVector a (args(1).float_complex_vector_value (errmsg));
 
           FloatComplexNDArray x (args(2).float_complex_array_value ());
 
+          FloatComplexNDArray si;
+
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
+
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
+
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
+
+              si.resize (si_dims, 0.0);
+            }
+          else
+            {
+              si = args(3).float_complex_array_value ();
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
           if (! error_state)
             {
-              FloatComplexNDArray si;
-
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.numel ();
-                  octave_idx_type b_len = b.numel ();
-
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+              FloatComplexNDArray y (filter (b, a, x, si, dim));
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).float_complex_array_value ();
-
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              if (nargout == 2)
+                retval(1) = si;
 
-              if (! error_state)
-                {
-                  FloatComplexNDArray y (filter (b, a, x, si, dim));
-
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              retval(0) = y;
             }
           else
             error (errmsg);
         }
       else
         {
-          ComplexColumnVector b (args(0).complex_vector_value ());
-          ComplexColumnVector a (args(1).complex_vector_value ());
+          ComplexColumnVector b (args(0).complex_vector_value (errmsg));
+          ComplexColumnVector a (args(1).complex_vector_value (errmsg));
 
           ComplexNDArray x (args(2).complex_array_value ());
 
+          ComplexNDArray si;
+
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
+
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
+
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
+
+              si.resize (si_dims, 0.0);
+            }
+          else
+            {
+              si = args(3).complex_array_value ();
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
           if (! error_state)
             {
-              ComplexNDArray si;
-
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.numel ();
-                  octave_idx_type b_len = b.numel ();
-
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+              ComplexNDArray y (filter (b, a, x, si, dim));
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).complex_array_value ();
-
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              if (nargout == 2)
+                retval(1) = si;
 
-              if (! error_state)
-                {
-                  ComplexNDArray y (filter (b, a, x, si, dim));
-
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              retval(0) = y;
             }
           else
             error (errmsg);
@@ -539,96 +529,86 @@
     {
       if (isfloat)
         {
-          FloatColumnVector b (args(0).float_vector_value ());
-          FloatColumnVector a (args(1).float_vector_value ());
+          FloatColumnVector b (args(0).float_vector_value (errmsg));
+          FloatColumnVector a (args(1).float_vector_value (errmsg));
 
           FloatNDArray x (args(2).float_array_value ());
 
+          FloatNDArray si;
+
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
+
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
+
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
+
+              si.resize (si_dims, 0.0);
+            }
+          else
+            {
+              si = args(3).float_array_value ();
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
           if (! error_state)
             {
-              FloatNDArray si;
-
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.numel ();
-                  octave_idx_type b_len = b.numel ();
-
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+              FloatNDArray y (filter (b, a, x, si, dim));
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).float_array_value ();
-
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              if (nargout == 2)
+                retval(1) = si;
 
-              if (! error_state)
-                {
-                  FloatNDArray y (filter (b, a, x, si, dim));
-
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              retval(0) = y;
             }
           else
             error (errmsg);
         }
       else
         {
-          ColumnVector b (args(0).vector_value ());
-          ColumnVector a (args(1).vector_value ());
+          ColumnVector b (args(0).vector_value (errmsg));
+          ColumnVector a (args(1).vector_value (errmsg));
 
           NDArray x (args(2).array_value ());
 
+          NDArray si;
+
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
+
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
+
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
+
+              si.resize (si_dims, 0.0);
+            }
+          else
+            {
+              si = args(3).array_value ();
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
           if (! error_state)
             {
-              NDArray si;
-
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.numel ();
-                  octave_idx_type b_len = b.numel ();
-
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+              NDArray y (filter (b, a, x, si, dim));
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).array_value ();
-
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              if (nargout == 2)
+                retval(1) = si;
 
-              if (! error_state)
-                {
-                  NDArray y (filter (b, a, x, si, dim));
-
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              retval(0) = y;
             }
           else
             error (errmsg);
--- a/libinterp/corefcn/graphics.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/graphics.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -9848,104 +9848,99 @@
   if (nargin > 0)
     {
       // get vector of graphics handles
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          bool request_drawnow = false;
-
-          // loop over graphics objects
-          for (octave_idx_type n = 0; n < hcv.numel (); n++)
-            {
-              graphics_object go = gh_manager::get_object (hcv(n));
-
-              if (go)
+      ColumnVector hcv (args(0).vector_value ("set: expecting graphics handle as first argument"));
+
+      bool request_drawnow = false;
+
+      // loop over graphics objects
+      for (octave_idx_type n = 0; n < hcv.numel (); n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            {
+              if (nargin == 3
+                  && args(1).is_cellstr () && args(2).is_cell ())
                 {
-                  if (nargin == 3
-                      && args(1).is_cellstr () && args(2).is_cell ())
+                  if (args(2).cell_value ().rows () == 1)
+                    {
+                      go.set (args(1).cellstr_value (),
+                              args(2).cell_value (), 0);
+                    }
+                  else if (hcv.numel () == args(2).cell_value ().rows ())
+                    {
+                      go.set (args(1).cellstr_value (),
+                              args(2).cell_value (), n);
+                    }
+                  else
                     {
-                      if (args(2).cell_value ().rows () == 1)
-                        {
-                          go.set (args(1).cellstr_value (),
-                                  args(2).cell_value (), 0);
-                        }
-                      else if (hcv.numel () == args(2).cell_value ().rows ())
-                        {
-                          go.set (args(1).cellstr_value (),
-                                  args(2).cell_value (), n);
-                        }
+                      error ("set: number of graphics handles must match number of value rows (%d != %d)",
+                             hcv.numel (), args(2).cell_value ().rows ());
+                      break;
+
+                    }
+                }
+              else if (nargin == 2 && args(1).is_map ())
+                {
+                  go.set (args(1).map_value ());
+                }
+              else if (nargin == 2 && args(1).is_string ())
+                {
+                  std::string property = args(1).string_value ();
+
+                  octave_map pmap = go.values_as_struct ();
+
+                  if (go.has_readonly_property (property))
+                    if (nargout != 0)
+                      retval = Matrix ();
+                    else
+                      octave_stdout << "set: " << property
+                                    <<" is read-only" << std::endl;
+                  else if (pmap.isfield (property))
+                    {
+                      if (nargout != 0)
+                        retval = pmap.getfield (property)(0);
                       else
                         {
-                          error ("set: number of graphics handles must match number of value rows (%d != %d)",
-                                 hcv.numel (), args(2).cell_value ().rows ());
-                          break;
-
-                        }
-                    }
-                  else if (nargin == 2 && args(1).is_map ())
-                    {
-                      go.set (args(1).map_value ());
-                    }
-                  else if (nargin == 2 && args(1).is_string ())
-                    {
-                      std::string property = args(1).string_value ();
-
-                      octave_map pmap = go.values_as_struct ();
-
-                      if (go.has_readonly_property (property))
-                        if (nargout != 0)
-                          retval = Matrix ();
-                        else
-                          octave_stdout << "set: " << property
-                                        <<" is read-only" << std::endl;
-                      else if (pmap.isfield (property))
-                        {
-                          if (nargout != 0)
-                            retval = pmap.getfield (property)(0);
-                          else
-                            {
-                              std::string s = go.value_as_string (property);
-
-                              octave_stdout << s;
-                            }
-                        }
-                      else
-                        {
-                          error ("set: unknown property");
-                          break;
-                        }
-                    }
-                  else if (nargin == 1)
-                    {
-                      if (nargout != 0)
-                        retval = go.values_as_struct ();
-                      else
-                        {
-                          std::string s = go.values_as_string ();
+                          std::string s = go.value_as_string (property);
 
                           octave_stdout << s;
                         }
                     }
                   else
                     {
-                      go.set (args.splice (0, 1));
-                      request_drawnow = true;
+                      error ("set: unknown property");
+                      break;
+                    }
+                }
+              else if (nargin == 1)
+                {
+                  if (nargout != 0)
+                    retval = go.values_as_struct ();
+                  else
+                    {
+                      std::string s = go.values_as_string ();
+
+                      octave_stdout << s;
                     }
                 }
               else
                 {
-                  error ("set: invalid handle (= %g)", hcv(n));
-                  break;
+                  go.set (args.splice (0, 1));
+                  request_drawnow = true;
                 }
-
-              request_drawnow = true;
-            }
-
-          if (request_drawnow)
-            Vdrawnow_requested = true;
-        }
-      else
-        error ("set: expecting graphics handle as first argument");
+            }
+          else
+            {
+              error ("set: invalid handle (= %g)", hcv(n));
+              break;
+            }
+
+          request_drawnow = true;
+        }
+
+      if (request_drawnow)
+        Vdrawnow_requested = true;
     }
   else
     print_usage ();
@@ -10000,88 +9995,83 @@
           return retval;
         }
 
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          octave_idx_type len = hcv.numel ();
-
-          if (nargin == 1 && len > 1)
-            {
-              std::string typ0 = get_graphics_object_type (hcv(0));
-
-              for (octave_idx_type n = 1; n < len; n++)
+      ColumnVector hcv (args(0).vector_value ("get: expecting graphics handle as first argument"));
+
+      octave_idx_type len = hcv.numel ();
+
+      if (nargin == 1 && len > 1)
+        {
+          std::string typ0 = get_graphics_object_type (hcv(0));
+
+          for (octave_idx_type n = 1; n < len; n++)
+            {
+              std::string typ = get_graphics_object_type (hcv(n));
+
+              if (typ != typ0)
                 {
-                  std::string typ = get_graphics_object_type (hcv(n));
-
-                  if (typ != typ0)
+                  error ("get: vector of handles must all have same type");
+                  break;
+                }
+            }
+        }
+
+      if (nargin > 1 && args(1).is_cellstr ())
+        {
+          Array<std::string> plist = args(1).cellstr_value ("get: expecting property name or cell array of property names as second argument");
+
+          octave_idx_type plen = plist.numel ();
+
+          use_cell_format = true;
+
+          vals.resize (dim_vector (len, plen));
+
+          for (octave_idx_type n = 0; n < len; n++)
+            {
+              graphics_object go = gh_manager::get_object (hcv(n));
+
+              if (go)
+                {
+                  for (octave_idx_type m = 0; m < plen; m++)
                     {
-                      error ("get: vector of handles must all have same type");
-                      break;
+                      caseless_str property = plist(m);
+
+                      vals(n, m) = go.get (property);
                     }
                 }
-            }
-
-          if (nargin > 1 && args(1).is_cellstr ())
-            {
-              Array<std::string> plist = args(1).cellstr_value ("get: expecting property name or cell array of property names as second argument");
-
-              octave_idx_type plen = plist.numel ();
-
-              use_cell_format = true;
-
-              vals.resize (dim_vector (len, plen));
-
-              for (octave_idx_type n = 0; n < len; n++)
+              else
                 {
-                  graphics_object go = gh_manager::get_object (hcv(n));
-
-                  if (go)
-                    {
-                      for (octave_idx_type m = 0; m < plen; m++)
-                        {
-                          caseless_str property = plist(m);
-
-                          vals(n, m) = go.get (property);
-                        }
-                    }
-                  else
-                    {
-                      error ("get: invalid handle (= %g)", hcv(n));
-                      break;
-                    }
-                }
-            }
-          else
-            {
-              caseless_str property;
-
-              if (nargin > 1)
-                property = args(1).string_value ("get: expecting property name or cell array of property names as second argument");
-
-              vals.resize (dim_vector (len, 1));
-
-              for (octave_idx_type n = 0; n < len; n++)
-                {
-                  graphics_object go = gh_manager::get_object (hcv(n));
-
-                  if (go)
-                    {
-                      if (nargin == 1)
-                        vals(n) = go.get ();
-                      else
-                        vals(n) = go.get (property);
-                    }
-                  else
-                    {
-                      error ("get: invalid handle (= %g)", hcv(n));
-                      break;
-                    }
+                  error ("get: invalid handle (= %g)", hcv(n));
+                  break;
                 }
             }
         }
       else
-        error ("get: expecting graphics handle as first argument");
+        {
+          caseless_str property;
+
+          if (nargin > 1)
+            property = args(1).string_value ("get: expecting property name or cell array of property names as second argument");
+
+          vals.resize (dim_vector (len, 1));
+
+          for (octave_idx_type n = 0; n < len; n++)
+            {
+              graphics_object go = gh_manager::get_object (hcv(n));
+
+              if (go)
+                {
+                  if (nargin == 1)
+                    vals(n) = go.get ();
+                  else
+                    vals(n) = go.get (property);
+                }
+              else
+                {
+                  error ("get: invalid handle (= %g)", hcv(n));
+                  break;
+                }
+            }
+        }
     }
   else
     print_usage ();
@@ -10136,29 +10126,24 @@
 
   if (nargin == 1)
     {
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          octave_idx_type len = hcv.numel ();
-
-          vals.resize (dim_vector (len, 1));
-
-          for (octave_idx_type n = 0; n < len; n++)
-            {
-              graphics_object go = gh_manager::get_object (hcv(n));
-
-              if (go)
-                vals(n) = go.get (true);
-              else
-                {
-                  error ("get: invalid handle (= %g)", hcv(n));
-                  break;
-                }
-            }
-        }
-      else
-        error ("get: expecting graphics handle as first argument");
+      ColumnVector hcv (args(0).vector_value ("get: expecting graphics handle as first argument"));
+
+      octave_idx_type len = hcv.numel ();
+
+      vals.resize (dim_vector (len, 1));
+
+      for (octave_idx_type n = 0; n < len; n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            vals(n) = go.get (true);
+          else
+            {
+              error ("get: invalid handle (= %g)", hcv(n));
+              break;
+            }
+        }
     }
   else
     print_usage ();
--- a/libinterp/corefcn/lsode.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/lsode.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -86,9 +86,9 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ("lsode: evaluation of user-supplied function failed");
 
-          if (error_state || retval.numel () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -404,25 +404,16 @@
       if (error_state || ! lsode_fcn)
         LSODE_ABORT ();
 
-      ColumnVector state (args(1).vector_value ());
-
-      if (error_state)
-        LSODE_ABORT1 ("expecting state vector as second argument");
+      ColumnVector state = args(1).vector_value ("lsode: expecting state vector as second argument");
 
-      ColumnVector out_times (args(2).vector_value ());
-
-      if (error_state)
-        LSODE_ABORT1 ("expecting output time vector as third argument");
+      ColumnVector out_times = args(2).vector_value ("lsode: expecting output time vector as third argument");
 
       ColumnVector crit_times;
 
       int crit_times_set = 0;
       if (nargin > 3)
         {
-          crit_times = ColumnVector (args(3).vector_value ());
-
-          if (error_state)
-            LSODE_ABORT1 ("expecting critical time vector as fourth argument");
+          crit_times = args(3).vector_value ("lsode: expecting critical time vector as fourth argument");
 
           crit_times_set = 1;
         }
--- a/libinterp/corefcn/matrix_type.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/matrix_type.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -276,27 +276,21 @@
               if (nargin == 3
                   && (str_typ == "upper" || str_typ == "lower"))
                 {
-                  const ColumnVector perm =
-                    ColumnVector (args(2).vector_value ());
+                  const ColumnVector perm (args(2).vector_value ("matrix_type: invalid permutation vector PERM"));
 
-                  if (error_state)
+                  octave_idx_type len = perm.numel ();
+                  dim_vector dv = args(0).dims ();
+
+                  if (len != dv(0))
                     error ("matrix_type: Invalid permutation vector PERM");
                   else
                     {
-                      octave_idx_type len = perm.numel ();
-                      dim_vector dv = args(0).dims ();
+                      OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
 
-                      if (len != dv(0))
-                        error ("matrix_type: Invalid permutation vector PERM");
-                      else
-                        {
-                          OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
+                      for (octave_idx_type i = 0; i < len; i++)
+                        p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
 
-                          for (octave_idx_type i = 0; i < len; i++)
-                            p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
-
-                          mattyp.mark_as_permuted (len, p);
-                        }
+                      mattyp.mark_as_permuted (len, p);
                     }
                 }
               else if (nargin != 2
@@ -422,27 +416,21 @@
 
               if (nargin == 3 && (str_typ == "upper" || str_typ == "lower"))
                 {
-                  const ColumnVector perm =
-                    ColumnVector (args(2).vector_value ());
+                  const ColumnVector perm (args(2).vector_value ("matrix_type: invalid permutation vector PERM"));
 
-                  if (error_state)
+                  octave_idx_type len = perm.numel ();
+                  dim_vector dv = args(0).dims ();
+
+                  if (len != dv(0))
                     error ("matrix_type: Invalid permutation vector PERM");
                   else
                     {
-                      octave_idx_type len = perm.numel ();
-                      dim_vector dv = args(0).dims ();
+                      OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
 
-                      if (len != dv(0))
-                        error ("matrix_type: Invalid permutation vector PERM");
-                      else
-                        {
-                          OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
+                      for (octave_idx_type i = 0; i < len; i++)
+                        p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
 
-                          for (octave_idx_type i = 0; i < len; i++)
-                            p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
-
-                          mattyp.mark_as_permuted (len, p);
-                        }
+                      mattyp.mark_as_permuted (len, p);
                     }
                 }
               else if (nargin != 2)
--- a/libinterp/corefcn/quad.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/quad.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -151,7 +151,7 @@
   do \
     { \
       if (fcn_name.length ()) \
-        clear_function (fcn_name); \
+       clear_function (fcn_name); \
       return retval; \
     } \
   while (0)
@@ -301,16 +301,10 @@
 
               have_sing = true;
 
-              sing = FloatColumnVector (args(4).float_vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of singularities as fourth argument");
+              sing = args(4).float_vector_value ("quad: expecting vector of singularities as fourth argument");
 
             case 4:
-              tol = FloatColumnVector (args(3).float_vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
+              tol = args(3).float_vector_value ("quad: expecting vector of tolerances as fifth argument");
 
               switch (tol.numel ())
                 {
@@ -410,16 +404,10 @@
 
               have_sing = true;
 
-              sing = ColumnVector (args(4).vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of singularities as fourth argument");
+              sing = args(4).vector_value ("quad: expecting vector of singularities as fourth argument");
 
             case 4:
-              tol = ColumnVector (args(3).vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
+              tol = args(3).vector_value ("quad: expecting vector of tolerances as fifth argument");
 
               switch (tol.numel ())
                 {
--- a/libinterp/corefcn/rand.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/corefcn/rand.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -271,8 +271,9 @@
                   octave_rand::reset (fcn);
                 else
                   {
-                    ColumnVector s =
-                      ColumnVector (args(idx+1).vector_value(false, true));
+                    Array<double> tmp = args(idx+1).array_value ();
+
+                    ColumnVector s = tmp.reshape (tmp.numel (), 1);
 
                     octave_rand::state (s, fcn);
                   }
--- a/libinterp/dldfcn/__eigs__.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/dldfcn/__eigs__.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -73,13 +73,7 @@
               warned_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
-
-          if (error_state)
-            {
-              eigs_error = 1;
-              gripe_user_supplied_eval ("eigs");
-            }
+          retval = tmp(0).vector_value ("eigs: evaluation of user-supplied function failed");
         }
       else
         {
@@ -111,13 +105,7 @@
 
       if (tmp.length () && tmp(0).is_defined ())
         {
-          retval = ComplexColumnVector (tmp(0).complex_vector_value ());
-
-          if (error_state)
-            {
-              eigs_error = 1;
-              gripe_user_supplied_eval ("eigs");
-            }
+          retval = tmp(0).complex_vector_value ("eigs: evaluation of user-supplied function failed");
         }
       else
         {
--- a/libinterp/dldfcn/__magick_read__.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/dldfcn/__magick_read__.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -770,12 +770,8 @@
     }
   else
     {
-      frameidx = indexes.int_vector_value ();
-      if (error_state)
-        {
-          error ("__magick_read__: invalid value for Index/Frame");
-          return output;
-        }
+      frameidx = indexes.int_vector_value ("__magick_read__: invalid value for Index/Frame");
+
       // Fix indexes from base 1 to base 0, and at the same time, make
       // sure none of the indexes is outside the range of image number.
       const octave_idx_type n = frameidx.numel ();
--- a/libinterp/octave-value/ov.cc	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/octave-value/ov.cc	Fri Nov 06 16:52:49 2015 -0500
@@ -1555,7 +1555,7 @@
 {
   Cell retval;
   va_list args;
-  va_start (args,fmt);
+  va_start (args, fmt);
   retval = rep->cell_value (fmt, args);
   va_end (args);
   return retval;
@@ -1690,6 +1690,31 @@
                                            type_name (), "real vector"));
 }
 
+Array<double>
+octave_value::vector_value (const char *fmt, ...) const
+{
+  Array<double> retval;
+
+  try
+    {
+      retval = vector_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        {
+          va_list args;
+          va_start (args, fmt);
+          verror (fmt, args);
+          va_end (args);
+        }
+
+      throw;
+    }
+
+  return retval;
+}
+
 template <class T>
 static Array<int>
 convert_to_int_array (const Array<octave_int<T> >& A)
@@ -1759,6 +1784,31 @@
                                            type_name (), "integer vector"));
 }
 
+Array<int>
+octave_value::int_vector_value (const char *fmt, ...) const
+{
+  Array<int> retval;
+
+  try
+    {
+      retval = int_vector_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        {
+          va_list args;
+          va_start (args, fmt);
+          verror (fmt, args);
+          va_end (args);
+        }
+
+      throw;
+    }
+
+  return retval;
+}
+
 template <class T>
 static Array<octave_idx_type>
 convert_to_octave_idx_type_array (const Array<octave_int<T> >& A)
@@ -1840,6 +1890,31 @@
                                            type_name (), "complex vector"));
 }
 
+Array<Complex>
+octave_value::complex_vector_value (const char *fmt, ...) const
+{
+  Array<Complex> retval;
+
+  try
+    {
+      retval = complex_vector_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        {
+          va_list args;
+          va_start (args, fmt);
+          verror (fmt, args);
+          va_end (args);
+        }
+
+      throw;
+    }
+
+  return retval;
+}
+
 FloatColumnVector
 octave_value::float_column_vector_value (bool force_string_conv,
                                          bool frc_vec_conv) const
@@ -1884,6 +1959,31 @@
                                            type_name (), "real vector"));
 }
 
+Array<float>
+octave_value::float_vector_value (const char *fmt, ...) const
+{
+  Array<float> retval;
+
+  try
+    {
+      retval = float_vector_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        {
+          va_list args;
+          va_start (args, fmt);
+          verror (fmt, args);
+          va_end (args);
+        }
+
+      throw;
+    }
+
+  return retval;
+}
+
 Array<FloatComplex>
 octave_value::float_complex_vector_value (bool force_string_conv,
                                           bool force_vector_conversion) const
@@ -1895,6 +1995,31 @@
                                            type_name (), "complex vector"));
 }
 
+Array<FloatComplex>
+octave_value::float_complex_vector_value (const char *fmt, ...) const
+{
+  Array<FloatComplex> retval;
+
+  try
+    {
+      retval = float_complex_vector_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        {
+          va_list args;
+          va_start (args, fmt);
+          verror (fmt, args);
+          va_end (args);
+        }
+
+      throw;
+    }
+
+  return retval;
+}
+
 octave_value
 octave_value::storable_value (void) const
 {
--- a/libinterp/octave-value/ov.h	Thu Nov 05 17:22:16 2015 -0500
+++ b/libinterp/octave-value/ov.h	Fri Nov 06 16:52:49 2015 -0500
@@ -903,7 +903,7 @@
   {
     std::string retval;
     va_list args;
-    va_start (args,fmt);
+    va_start (args, fmt);
     retval = rep->string_value (fmt, args);
     va_end (args);
     return retval;
@@ -916,7 +916,7 @@
   {
     Array<std::string> retval;
     va_list args;
-    va_start (args,fmt);
+    va_start (args, fmt);
     retval = rep->cellstr_value (fmt, args);
     va_end (args);
     return retval;
@@ -998,6 +998,8 @@
                                bool frc_str_conv = false,
                                bool frc_vec_conv = false) const;
 
+  Array<int> int_vector_value (const char *fmt, ...) const;
+
   Array<octave_idx_type>
   octave_idx_type_vector_value (bool req_int = false,
                                 bool frc_str_conv = false,
@@ -1006,16 +1008,24 @@
   Array<double> vector_value (bool frc_str_conv = false,
                               bool frc_vec_conv = false) const;
 
+  Array<double> vector_value (const char *fmt, ...) const;
+
   Array<Complex> complex_vector_value (bool frc_str_conv = false,
                                        bool frc_vec_conv = false) const;
 
+  Array<Complex> complex_vector_value (const char *fmt, ...) const;
+
   Array<float> float_vector_value (bool frc_str_conv = false,
                                    bool frc_vec_conv = false) const;
 
+  Array<float> float_vector_value (const char *fmt, ...) const;
+
   Array<FloatComplex>
   float_complex_vector_value (bool frc_str_conv = false,
                               bool frc_vec_conv = false) const;
 
+  Array<FloatComplex> float_complex_vector_value (const char *fmt, ...) const;
+
   // Possibly economize a lazy-indexed value.
 
   void maybe_economize (void)