Add TooManySkillsOfTypeError

This commit is contained in:
Justin Edmund 2022-12-02 20:45:46 -08:00
parent 644ffd74e5
commit f6613d6e91
2 changed files with 32 additions and 0 deletions

View file

@ -12,6 +12,7 @@ module Api::V1
rescue_from Api::V1::SameFavoriteUserError, 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::TooManySkillsOfTypeError, with: :render_unprocessable_entity_response
rescue_from Api::V1::UnauthorizedError, with: :render_unauthorized_response
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response

View 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