Exception: Pechkin::AppError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/pechkin/app/app_error.rb

Overview

Generic application error class.

Allows us return meaningful error messages

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, msg) ⇒ AppError

Returns a new instance of AppError.



8
9
10
11
# File 'lib/pechkin/app/app_error.rb', line 8

def initialize(code, msg)
  super(msg)
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/pechkin/app/app_error.rb', line 6

def code
  @code
end

Class Method Details

.bad_request(message) ⇒ Object



14
15
16
# File 'lib/pechkin/app/app_error.rb', line 14

def bad_request(message)
  AppError.new(503, message)
end

.http_method_not_allowedObject



22
23
24
# File 'lib/pechkin/app/app_error.rb', line 22

def http_method_not_allowed
  AppError.new(405, 'method not allowed')
end

.message_not_foundObject



18
19
20
# File 'lib/pechkin/app/app_error.rb', line 18

def message_not_found
  AppError.new(404, 'message not found')
end