Sha256: 2e1bc0e25c934258f25b7e80f451b47c6a0a94257b481ff575c50c9398420c20

Contents?: true

Size: 836 Bytes

Versions: 48

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

class Tramway::Error < RuntimeError
  def initialize(*args, plugin: nil, method: nil, message: nil)
    @properties = {}
    @properties[:plugin] = plugin
    @properties[:method] = method
    @properties[:message] = message
    super(*args)
  end

  def message
    "Plugin: #{@properties[:plugin]}; Method: #{@properties[:method]}; Message: #{@properties[:message]}"
  end

  def properties
    @properties ||= {}
  end

  class << self
    def raise_error(*coordinates, **options)
      @errors ||= YAML.load_file("#{Tramway::Core.root}/yaml/errors.yml").with_indifferent_access
      error = @errors.dig(*coordinates)
      raise 'Error is not defined in YAML' unless error

      options.each do |pair|
        error.gsub!("%{#{pair[0]}}", pair[1].to_s)
      end
      raise error
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
tramway-core-5.0 lib/tramway/error.rb
tramway-core-4.1.3.3 lib/tramway/error.rb
tramway-core-4.1.3.2 lib/tramway/error.rb
tramway-core-4.1.3.1 lib/tramway/error.rb
tramway-core-4.1.3 lib/tramway/error.rb
tramway-core-4.1.2 lib/tramway/error.rb
tramway-core-4.1.1 lib/tramway/error.rb
tramway-core-4.1 lib/tramway/error.rb
tramway-core-4.0.2.1 lib/tramway/error.rb
tramway-core-4.0.2 lib/tramway/error.rb
tramway-core-4.0.1.2 lib/tramway/error.rb
tramway-core-4.0.1.1 lib/tramway/error.rb
tramway-core-4.0.1 lib/tramway/error.rb
tramway-core-4.0.0.1 lib/tramway/error.rb
tramway-core-4.0 lib/tramway/error.rb
tramway-core-3.0.1.1 lib/tramway/error.rb
tramway-core-3.0.1 lib/tramway/error.rb
tramway-core-3.0.0.2 lib/tramway/error.rb
tramway-core-3.0.0.1 lib/tramway/error.rb
tramway-core-3.0 lib/tramway/error.rb