Exception: UsageError

Inherits:
RuntimeError
  • Object
show all
Defined in:
Library/Homebrew/exceptions.rb

Overview

Raised when a command is used wrong.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason = nil) ⇒ UsageError

Returns a new instance of UsageError.


10
11
12
13
14
# File 'Library/Homebrew/exceptions.rb', line 10

def initialize(reason = nil)
  super

  @reason = reason
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason


8
9
10
# File 'Library/Homebrew/exceptions.rb', line 8

def reason
  @reason
end

Instance Method Details

#to_sObject


16
17
18
19
20
# File 'Library/Homebrew/exceptions.rb', line 16

def to_s
  s = "Invalid usage"
  s += ": #{reason}" if reason
  s
end