From: Christopher Dicely Date: 2010-02-14T08:25:43+09:00 Subject: Re: What is the best exception to use for bad Data State? On Sat, Feb 13, 2010 at 9:10 AM, Xeno Campanoli wrote: > 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: From what I've seen, it seems more idiomatic in Ruby not to define "pure virtual" methods, and instead describe methods that must be provided in child classes in the parent classes docs. Pure virtual methods in static languages mostly exist to allow code to compile that targets the generic interface of the class, but since Ruby doesn't have static variable typing and compile-time checking that method calls are valid for the type of the variable they are called against, there doesn't seem to be a whole lot of reason to actually define a pure virtual method. If a call is made to an undefined method, you'll normally (unless you've, e.g., done something with method_missing that redirects the call) get a NoMethodError exception thrown.