Exception: RestApiGenerator::CustomError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rest_api_generator/custom_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error: 422, status: :unprocessable_entity, message: "Something went wrong") ⇒ CustomError

Returns a new instance of CustomError.



7
8
9
10
11
12
# File 'lib/rest_api_generator/custom_error.rb', line 7

def initialize(error: 422, status: :unprocessable_entity, message: "Something went wrong")
  @error = error
  @status = status
  @message = message
  super(msg: message)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/rest_api_generator/custom_error.rb', line 5

def error
  @error
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/rest_api_generator/custom_error.rb', line 5

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/rest_api_generator/custom_error.rb', line 5

def status
  @status
end

Instance Method Details

#fetch_jsonObject



14
15
16
# File 'lib/rest_api_generator/custom_error.rb', line 14

def fetch_json
  Helpers::Render.json(error, message, status)
end