diff libinterp/corefcn/rand.cc @ 20743:b6408331bfa2

eliminate more uses of error_state * graphics.cc, input.cc, max.cc, rand.cc, __eigs__.cc, ov-class.cc, ov-classdef.cc, ov.cc, octave.cc: Eliminate more uses of error_state.
author John W. Eaton <jwe@octave.org>
date Mon, 23 Nov 2015 23:23:57 -0500
parents 7b608fadc663
children 200ae1d650b7
line wrap: on
line diff
--- a/libinterp/corefcn/rand.cc	Mon Nov 23 21:00:14 2015 -0500
+++ b/libinterp/corefcn/rand.cc	Mon Nov 23 23:23:57 2015 -0500
@@ -208,26 +208,30 @@
           }
         else if (tmp.is_matrix_type ())
           {
-            Array<int> iv = tmp.int_vector_value (true);
+            Array<int> iv;
 
-            if (! error_state)
+            try
               {
-                octave_idx_type len = iv.numel ();
-
-                dims.resize (len);
+                iv = tmp.int_vector_value (true);
+              }
+            catch (const octave_execution_exception&)
+              {
+                error ("%s: dimensions must be a scalar or array of integers", fcn);
+              }
 
-                for (octave_idx_type i = 0; i < len; i++)
-                  {
-                    // Negative dimensions are treated as zero for Matlab
-                    // compatibility
-                    octave_idx_type elt = iv(i);
-                    dims(i) = elt >=0 ? elt : 0;
-                  }
+            octave_idx_type len = iv.numel ();
+
+            dims.resize (len);
 
-                goto gen_matrix;
+            for (octave_idx_type i = 0; i < len; i++)
+              {
+                // Negative dimensions are treated as zero for Matlab
+                // compatibility
+                octave_idx_type elt = iv(i);
+                dims(i) = elt >=0 ? elt : 0;
               }
-            else
-              error ("%s: dimensions must be a scalar or array of integers", fcn);
+
+            goto gen_matrix;
           }
         else
           {