Sha256: abbcd453f5adddeec61dc862ef4e8207e029b38fc627fd823d197050a9c7acdb

Contents?: true

Size: 759 Bytes

Versions: 11

Compression:

Stored size: 759 Bytes

Contents

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
nestene-0.2.1 lib/nestene/execution_error.rb
nestene-0.2.0 lib/nestene/execution_error.rb
nestene-0.1.8 lib/nestene/execution_error.rb
nestene-0.1.7 lib/nestene/execution_error.rb
nestene-0.1.6 lib/nestene/execution_error.rb
nestene-0.1.5 lib/nestene/execution_error.rb
nestene-0.1.4 lib/nestene/execution_error.rb
nestene-0.1.3 lib/nestene/execution_error.rb
nestene-0.1.2 lib/nestene/execution_error.rb
nestene-0.1.1 lib/nestene/execution_error.rb
nestene-0.1.0 lib/nestene/execution_error.rb