Exception: CircularDependencyError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/dep_check/CircularDependencyError.rb

Overview

循环依赖检测时用到的一个异常类型,便于抛异常时传递参数

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, path, message = 'Circular dependency detected!') ⇒ CircularDependencyError

Returns a new instance of CircularDependencyError.

Parameters:

  • from (String)

    循环依赖上端点

  • to (String)

    循环依赖下端点

  • path (Array<String>)

    循环依赖路径上的节点名

  • message (String) (defaults to: 'Circular dependency detected!')

    附加消息



12
13
14
15
16
17
# File 'lib/dep_check/CircularDependencyError.rb', line 12

def initialize(from, to , path , message = 'Circular dependency detected!')
  @from = from
  @to = to
  @path = path
  @message = message
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/dep_check/CircularDependencyError.rb', line 3

def from
  @from
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/dep_check/CircularDependencyError.rb', line 6

def message
  @message
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/dep_check/CircularDependencyError.rb', line 5

def path
  @path
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/dep_check/CircularDependencyError.rb', line 4

def to
  @to
end

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
# File 'lib/dep_check/CircularDependencyError.rb', line 19

def to_s
  path_message = String.new
  @path.each { |name|
    path_message << name + '--->'
  }
  path_message << @to

  "#{super} \n #{@message} \n #{@from} <---> #{@to} . \n Full Path: #{path_message} "
end