Add TooManySkillsOfTypeError
This commit is contained in:
parent
644ffd74e5
commit
f6613d6e91
2 changed files with 32 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ module Api::V1
|
||||||
rescue_from Api::V1::SameFavoriteUserError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::SameFavoriteUserError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::FavoriteAlreadyExistsError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::FavoriteAlreadyExistsError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::NoJobProvidedError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::NoJobProvidedError, with: :render_unprocessable_entity_response
|
||||||
|
rescue_from Api::V1::TooManySkillsOfTypeError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::UnauthorizedError, with: :render_unauthorized_response
|
rescue_from Api::V1::UnauthorizedError, with: :render_unauthorized_response
|
||||||
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response
|
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response
|
||||||
|
|
||||||
|
|
|
||||||
31
app/errors/api/v1/TooManySkillsOfTypeError.rb
Normal file
31
app/errors/api/v1/TooManySkillsOfTypeError.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Api
|
||||||
|
module V1
|
||||||
|
class TooManySkillsOfTypeError < StandardError
|
||||||
|
def initialize(data)
|
||||||
|
@data = data
|
||||||
|
end
|
||||||
|
|
||||||
|
def http_status
|
||||||
|
422
|
||||||
|
end
|
||||||
|
|
||||||
|
def code
|
||||||
|
'too_many_skills_of_type'
|
||||||
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
'You can only have up to 2 skills of type'
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_hash
|
||||||
|
{
|
||||||
|
message: message,
|
||||||
|
code: code,
|
||||||
|
idea_id: @data[:skill_type]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue