octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error function


From: Shai Ayal
Subject: Re: error function
Date: Mon, 14 May 2007 22:10:19 +0300

On 5/14/07, John W. Eaton <address@hidden> wrote:
On 14-May-2007, Shai Ayal wrote:

| In the process of adding new graphics property types (sorry it's
| taking soooo long), I came upon the error function. Can someone
| explain it to me?
| does it throw an exception?

No.

| what does it do except setting the error_state flag?

It prints the message, sets error_state, and saves information about
the error for lasterror/lasterr/rethrow.

| when will the error message be printed?

Immediately.

| Is it the "recommended" way to handle errors of the sort of
| incompatible assignments -- i.e. trying to assing a number to a string
| type?

Can you give an example of what you are trying to do?

I am trying to implement a color_property which can aslo have
radio_values, i.e. it can be a rgb triplet or "auto" or "none".

let's say I want to get the rgb value from the color_property. first I
want to check that the value is not "auto". I thight of something
along the lines of

 const double* color_property::rgb (void) const
 {
   if (current_type != color)
     error ("color has no rgb value");

   return color.rgb ();
 }

where current_type determines if the color_property's value is a color
or radio_value and color is the internal color_value object which has
a rgb () method.

so in a code using these properties, I would do:

const double* lc = linecolor.rgb ();
if (!error_state)
 glColor3d(lc);
...
this is similar to checking the input argument type in a DLD function.
Does this seem OK?

S.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]