app/controllers/qa/terms_controller.rb in qa-3.1.0 vs app/controllers/qa/terms_controller.rb in qa-4.0.0.rc1

- old
+ new

@@ -32,35 +32,43 @@ cors_allow_origin_header(response) render json: term end def check_vocab_param - head :not_found unless params[:vocab].present? + return if params[:vocab].present? + msg = "Required param 'vocab' is missing or empty" + logger.warn msg + render json: { errors: msg }, status: :bad_request end def init_authority # rubocop:disable Metrics/MethodLength begin mod = authority_class.camelize.constantize rescue NameError - logger.warn "Unable to initialize authority #{authority_class}" - head :not_found + msg = "Unable to initialize authority #{authority_class}" + logger.warn msg + render json: { errors: msg }, status: :bad_request return end begin @authority = if mod.is_a? Class mod.new else raise Qa::MissingSubAuthority, "No sub-authority provided" if params[:subauthority].blank? mod.subauthority_for(params[:subauthority]) end rescue Qa::InvalidSubAuthority, Qa::MissingSubAuthority => e - logger.warn e.message - head :not_found + msg = e.message + logger.warn msg + render json: { errors: msg }, status: :bad_request end end def check_query_param - head :not_found unless params[:q].present? + return if params[:q].present? + msg = "Required param 'q' is missing or empty" + logger.warn msg + render json: { errors: msg }, status: :bad_request end private def authority_class