On Thu, Nov 29, 2012 at 3:47 AM, comopasta Gr <[email protected]> wrote:
> error_type = Struct.new(:code, :description)
> BAD_JSON = error_type.new("001" , "Problem parsing JSON")
> BAD_XML = error_type.new("002" , "Problem parsing XML")
class MyClass
class APIParseError < StandardError
def initialize(code, lib)
@code = code
@lib = lib
end
def to_s
"#{@code}: Problem parsing #{@lib}"
end
end
end
raise(MyClass::APIParseError.new("001", :XML))
#=> MyClass::MyError: 001: Problem parsing XML
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.