Adding more details to Exception object

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.

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 G. [email protected]