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.



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

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

Instance Attribute Details

#instanceObject

Returns the value of attribute instance.



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

def instance
  @instance
end

Instance Method Details

#color_error(instance_type, instance, result) ⇒ Object



32
33
34
35
36
# File 'lib/warp/dir/errors.rb', line 32

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

#nameObject



28
29
30
# File 'lib/warp/dir/errors.rb', line 28

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