Class: PullRequestAi::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/pull_request_ai/util/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, message = nil) ⇒ Error

Returns a new instance of Error.



7
8
9
10
# File 'lib/pull_request_ai/util/error.rb', line 7

def initialize(symbol, message = nil)
  @symbol = symbol
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/pull_request_ai/util/error.rb', line 5

def message
  @message
end

#symbolObject (readonly)

Returns the value of attribute symbol.



5
6
7
# File 'lib/pull_request_ai/util/error.rb', line 5

def symbol
  @symbol
end

Class Method Details

.failure(symbol, message = nil) ⇒ Object



22
23
24
25
# File 'lib/pull_request_ai/util/error.rb', line 22

def failure(symbol, message = nil)
  new_instance = new(symbol, message)
  Dry::Monads::Failure(new_instance)
end

Instance Method Details

#descriptionObject



12
13
14
15
16
17
18
19
# File 'lib/pull_request_ai/util/error.rb', line 12

def description
  error_desc = SYMBOL_DETAILS[symbol]
  if error_desc
    error_desc + (message ? " #{message}" : '')
  else
    message || symbol.to_s
  end
end