diff libinterp/octave-value/ov-struct.cc @ 15731:18f168880226

error_ids: Adding ids and documentation error_ids.m: Added ID Octave:bad-alloc and Octave:undefined-function error.txi: Added section that explains how to catch errors with ids for this I needed a working example. I chose the ID Octave:invalid-indexing. ov-struct.cc: When a structure is indexed with a field it doesn't have the error now returns the corresponding ID Octave:invalid-indexing.
author Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
date Tue, 04 Dec 2012 20:06:49 +0100
parents f2b8f90052fd
children c33594eefda7
line wrap: on
line diff
--- a/libinterp/octave-value/ov-struct.cc	Tue Dec 04 16:40:22 2012 -0500
+++ b/libinterp/octave-value/ov-struct.cc	Tue Dec 04 20:06:49 2012 +0100
@@ -85,7 +85,8 @@
   else if (auto_add)
     retval = (numel () == 0) ? Cell (dim_vector (1, 1)) : Cell (dims ());
   else
-    error ("structure has no member '%s'", nm.c_str ());
+    error_with_id ("Octave:invalid-indexing", 
+                   "structure has no member '%s'", nm.c_str ());
 
   return retval;
 }
@@ -1143,7 +1144,8 @@
   retval = map.getfield (nm);
 
   if (! auto_add && retval.is_undefined ())
-    error ("structure has no member '%s'", nm.c_str ());
+    error_with_id ("Octave:invalid-indexing",
+                   "structure has no member '%s'", nm.c_str ());
 
   return retval;
 }