diff scripts/plot/private/__pie__.m @ 11338:892ef3688ccf

__pie__.m: improve error messages
author John W. Eaton <jwe@octave.org>
date Thu, 09 Dec 2010 19:24:00 -0500
parents 4d0cfbe59fd2
children 3c7ba1e3dc21
line wrap: on
line diff
--- a/scripts/plot/private/__pie__.m	Thu Dec 09 19:03:56 2010 -0500
+++ b/scripts/plot/private/__pie__.m	Thu Dec 09 19:24:00 2010 -0500
@@ -29,7 +29,7 @@
   iarg = 3;
 
   if (! isvector (x))
-    error ("__pie__: expecting vector argument");
+    error ("%s: expecting vector argument", caller);
   endif
 
   len = length (x);
@@ -43,14 +43,17 @@
       labels = arg;
       have_labels = true;
       if (numel (x) != numel (labels))
-        error ("__pie__: mismatch in number of labels and data");
+        error ("%s: mismatch in number of labels and data", caller);
       endif
-    elseif (! ischar (arg))
+    elseif (isnumeric (arg) || islogical (arg))
       explode = arg;
       have_explode = true;
       if (! size_equal (x, explode))
-        error ("__pie__: mismatch in number of elements in explode and data");
+        error ("%s: mismatch in number of elements in explode and data",
+               caller);
       endif
+    else
+      error ("%s: %s is invalid as an optional argument", caller, class (arg));
     endif
   endwhile
 
@@ -122,7 +125,7 @@
                text(xt, yt, labels{i}, "horizontalalignment", align)];
 
     else
-      error ("__pie__: unknown caller");
+      error ("__pie__: unknown caller `%s'", caller);
     endif
   endfor