Exception: Warp::Dir::Errors::InstanceError

Inherits:
Runtime show all
Defined in:
lib/warp/dir/errors.rb

Overview

This is a generic Exception that wraps an object passed to the initializer and assumed to be the reason for the failure. Message is optional, but each concrete exception should provide it’s own concrete message

Direct Known Subclasses

InvalidCommand, PointAlreadyExists, PointNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil) ⇒ InstanceError

Returns a new instance of InstanceError.



26
27
28
# File 'lib/warp/dir/errors.rb', line 26

def initialize(message = nil)
  super message ? message : "#{self.class.name}->[#{instance}]"
end

Instance Attribute Details

#instanceObject

Returns the value of attribute instance.



24
25
26
# File 'lib/warp/dir/errors.rb', line 24

def instance
  @instance
end

Instance Method Details

#color_error(instance_type, instance, result) ⇒ Object



34
35
36
37
38
# File 'lib/warp/dir/errors.rb', line 34

def color_error instance_type, instance, result
  instance_type.red.bold +
    instance.to_s.yellow.bold +
    result.red.bold
end

#nameObject



30
31
32
# File 'lib/warp/dir/errors.rb', line 30

def name
  super.gsub(%r{#{self.class.name}}, '')
end