Exception: Virtuaservices::Utils::Errors::HTTPError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/virtuaservices/utils/errors/http_error.rb

Overview

Standard class parent to all specialized http errors.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action, field, error, status) ⇒ HTTPError

Returns a new instance of HTTPError.



21
22
23
24
25
26
# File 'lib/virtuaservices/utils/errors/http_error.rb', line 21

def initialize (action, field, error, status)
  @action = action
  @field = field.to_s
  @error = error
  @status = status
end

Instance Attribute Details

#actionString

Returns the name of the action the user was trying to perform on the model (often crate or update).

Returns:

  • (String)

    the name of the action the user was trying to perform on the model (often crate or update).



13
14
15
# File 'lib/virtuaservices/utils/errors/http_error.rb', line 13

def action
  @action
end

#errorString

Returns the label of the error returned by the model.

Returns:

  • (String)

    the label of the error returned by the model.



16
17
18
# File 'lib/virtuaservices/utils/errors/http_error.rb', line 16

def error
  @error
end

#fieldString, Symbol

Returns the name of the field in error in the model.

Returns:

  • (String, Symbol)

    the name of the field in error in the model.



10
11
12
# File 'lib/virtuaservices/utils/errors/http_error.rb', line 10

def field
  @field
end

#statusInteger

Returns the HTTP status code as a number (eg: 400, 422 or 500).

Returns:

  • (Integer)

    the HTTP status code as a number (eg: 400, 422 or 500)



19
20
21
# File 'lib/virtuaservices/utils/errors/http_error.rb', line 19

def status
  @status
end