Make your own exception:
class CustomException < StandardError
attr :message, :details
def initialize(message, details)
@message = message
@details = details
end
end
On Feb 6, 11:18 am, Aryk Grosz
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I know that the default ruby Exception object holds message and
> backtrace.
>
> Sometimes I want to specify variable names and values to the Exception
> object so that I can email myself the details in the exception_notifier.
>
> I know I could subclass Exception to add more details to it, but I dont
> want to have to recreate all the classes for exceptions that already
> exist (ArgumentError,IOError, etc).
>
> I also know that I could tack on all the info in the message but that
> would get very messy since the message is usually in the subject of my
> error emails.
>
> I want to be able to do :
>
> raise ArgumentError.new(msg, details)
>
> Should I try something like
>
> class Exception
> attr_accessor :details
> def initialize(msg, details)
>
> end
> end
>
> which probably wont work since its a builtin function and there is only
> stub code for it.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---