From: "Iñaki Baz Castillo" Date: 2011-05-02T06:02:40+09:00 Subject: Re: Is it usual/valid to extend custom classes under Errno module? 2011/5/1 Christopher Dicely : > If you are writing an asynchronous, non-blocking DNS library on top of > EventMachine, and returning results the same way you get them back > (via callbacks), then, yeah, raising an exception is just going to > cause all kinds of problems. Yes, non-blocking paradigm breaks all the rules (joking) :) > You could probably return (not raise) an exception (have a separate > Exception class for each broad type of errors, and populated it with > the appropriate details; this seems to be approximately what your > Errno based approach would do -- Errno, after all, is a descendant of > Exception) in your error callbacks. > > OTOH, if you aren't going to be providing any additional information > other than the general type of error, either a symbol or an opaque > constant defined in your library works just as well. Thanks. The C library on top of my Ruby library (udns) returns 3-4 kinds of error, and being DNS they are self-descriptive (no more info is required). Basically "domain not found", "resource record not found", "malformed response", "timeout", so for now I'm done with 4 Symbols. But yes, perhaps I will change and return an instance of a custom error class (in fact the same instance always, the one generated within the Ruby C extension, as no more info is required in the error). Thanks a lot. -- Iñaki Baz Castillo