changeset 11338:892ef3688ccf

__pie__.m: improve error messages
author John W. Eaton <jwe@octave.org>
date Thu, 09 Dec 2010 19:24:00 -0500
parents 24cbdeac8384
children 97b12d801b02
files scripts/ChangeLog scripts/plot/private/__pie__.m
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Dec 09 19:03:56 2010 -0500
+++ b/scripts/ChangeLog	Thu Dec 09 19:24:00 2010 -0500
@@ -1,3 +1,9 @@
+2010-12-09  John W. Eaton  <jwe@octave.org>
+
+	* plot/private/__pie__.m: Provide diagnositc for invalid
+	optional arguments.  Use caller name instead of __pie__ in error
+	messages.
+
 2010-12-09  John W. Eaton  <jwe@octave.org>
 
 	* statistics/tests/kolmogorov_smirnov_test.m: Try both DIST_cdf
--- 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