From: Xeno Campanoli on
I don't want to use "ArgumentError" as this is a matter of data that may be
programmed in a daughter class, and is not necessarily an argument.
Specifically, the state of some object variables in this case.
--
"It's the preponderance, stupid!" - Professor Stephen Schneider, IPCC member

From: Robert Klemme on
On 02/13/2010 02:16 AM, Xeno Campanoli wrote:
> I don't want to use "ArgumentError" as this is a matter of data that may be
> programmed in a daughter class, and is not necessarily an argument.
> Specifically, the state of some object variables in this case.

Can you provide more context information? When do you want to throw?

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
From: Mat Brown on
On Sat, Feb 13, 2010 at 03:10, Robert Klemme <shortcutter(a)googlemail.com> wrote:
> On 02/13/2010 02:16 AM, Xeno Campanoli wrote:
>>
>> I don't want to use "ArgumentError" as this is a matter of data that may
>> be programmed in a daughter class, and is not necessarily an argument.
>> Specifically, the state of some object variables in this case.
>
> Can you provide more context information?  When do you want to throw?
>
> Kind regards
>
>        robert
>
> --
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
>
>

Sounds like Xeno is looking for something equivalent to Java's
IllegalStateException:
http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html

As far as I know, Ruby doesn't have a built-in exception with similar
semantics. So the best bet would be to define your own.

From: Xeno Campanoli on
Robert Klemme wrote:
> On 02/13/2010 02:16 AM, Xeno Campanoli wrote:
>> I don't want to use "ArgumentError" as this is a matter of data that
>> may be programmed in a daughter class, and is not necessarily an
>> argument. Specifically, the state of some object variables in this case.
>
> Can you provide more context information? When do you want to throw?
>
> Kind regards
>
> robert
>

For now I am using "ScriptError". I was using "SyntaxError", but I think that
was just wrong. Here are some places:

I have what I want to be pure virtual methods in a base class:

def myPureVirtualMethod
raise ScriptError, "This should never be called. Daughter Classes MUST define
their own."
end

then there is

def validateThatThingMadeByPureVirtualMethodIsThere
unless theThingMMadeByPureVirtualMethodIsThere?
raise ScriptError, "That thingy isn't there."
end
end

--
"It's the preponderance, stupid!" - Professor Stephen Schneider, IPCC member

From: Brian Candler on
Xeno Campanoli wrote:
> def myPureVirtualMethod
> raise ScriptError, "This should never be called. Daughter Classes
> MUST define
> their own."
> end

raise NoMethodError perhaps?

> def validateThatThingMadeByPureVirtualMethodIsThere
> unless theThingMMadeByPureVirtualMethodIsThere?
> raise ScriptError, "That thingy isn't there."
> end
> end

raise "That thingy isn't there" # RuntimeError

class MissingThingyErrror < RuntimeError; end
raise MissingThingyError, "That thingy isn't there"
--
Posted via http://www.ruby-forum.com/.