def marshal_exception(exception)
data = {
:message => exception.message,
:class => exception.class.to_s,
:backtrace => exception.backtrace
}
if exception.is_a?(InitializationError)
data[:is_initialization_error] = true
if exception.child_exception
data[:child_exception] = marshal_exception(exception.child_exception)
child_exception = exception.child_exception
exception.child_exception = nil
data[:exception] = Marshal.dump(exception)
exception.child_exception = child_exception
end
else
begin
data[:exception] = Marshal.dump(exception)
rescue ArgumentError, TypeError
e = UnknownError.new(exception.message, exception.class.to_s,
exception.backtrace)
data[:exception] = Marshal.dump(e)
end
end
return Marshal.dump(data)
end