module Nestene class ExecutionError include StructureMapper::Hash def initialize(exception = nil) if exception self.message = exception.message self.type = exception.class.name self.backtrace = exception.backtrace end end attribute message: String attribute type: String attribute backtrace: [String] def to_exception exception = Nestene.class_from_string(type).new(message) exception.set_backtrace self.backtrace exception end end end class Exception def to_structure Nestene::ExecutionError.new(self).to_structure end def self.from_structure structure structure ? Nestene::ExecutionError.from_structure(structure).to_exception : nil end end