Exception: Interceptors::AppError

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

Direct Known Subclasses

AuthError, ValidationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = "Application error", code: "app_error", http_status: 400, details: {}) ⇒ AppError

Returns a new instance of AppError.



7
8
9
10
11
12
# File 'lib/interceptors/app_error.rb', line 7

def initialize(message = "Application error", code: "app_error", http_status: 400, details: {})
  super(message)
  @code = code
  @http_status = http_status
  @details = details || {}
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/interceptors/app_error.rb', line 5

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



5
6
7
# File 'lib/interceptors/app_error.rb', line 5

def details
  @details
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



5
6
7
# File 'lib/interceptors/app_error.rb', line 5

def http_status
  @http_status
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
# File 'lib/interceptors/app_error.rb', line 14

def to_h
  {
    message: message,
    code: code,
    http_status: http_status,
    details: details
  }
end