On Fri, Aug 21, 2009 at 6:35 AM, Ben Giddings<bg-rubytalk / infofiend.com> wrote:
> On Aug 20, 2009, at 14:49, Gary Wright wrote:
> If you're writing calculate_bounding_box() as a bit of library code that
> will be used by other programmers, it is nice to provide helpful error
> messages.
>
> Someone using the method calculate_bounding_box() has no way of knowing that
> you're calling "ceil" internally, so getting an error back saying
> "NoMethodError: undefined method `ceil' for "2343":String" will be
> confusing.

He will know when he sees that error, if it wasn't in the
documentation of the method.

> If you are nice enough to catch that error and throw a more useful error:
> "ArgumentError: width and height must be numeric" it will make debugging
> much easier.

The duck typing philosophy says that the argument need not be Numeric,
only respond to "ceil" :-)
So if you change ArgumentError to say: "#{x} should respond to :ceil",
isn't that pretty similar to the NoMethodError?

Jesus.