Exception: Tramway::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/tramway/error.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, plugin: nil, method: nil, message: nil) ⇒ Error

Returns a new instance of Error.



4
5
6
7
8
9
10
# File 'lib/tramway/error.rb', line 4

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

Class Method Details

.raise_error(*coordinates, **options) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/tramway/error.rb', line 21

def raise_error(*coordinates, **options)
  @errors ||= YAML.load_file("#{Tramway::Core.root}/yaml/errors.yml").with_indifferent_access
  error = @errors.dig(*coordinates)
  options.each do |pair|
    error.gsub!("%{#{pair[0]}}", pair[1].to_s)
  end
  raise error
end

Instance Method Details

#messageObject



12
13
14
# File 'lib/tramway/error.rb', line 12

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

#propertiesObject



16
17
18
# File 'lib/tramway/error.rb', line 16

def properties
  @properties ||= {}
end