require 'fiona7/controllers/rest_api/error_handler' module Fiona7 class ApiController < ActionController::Base def perform path = params[:path].to_s verb = params[:verb].to_s.downcase.to_sym payload = params[:params] render json: Scrivito::CmsRestApi.task_unaware_request(verb, path, payload) rescue *Fiona7::ErrorHandler::HANDLED_ERRORS => e message = Fiona7::ErrorHandler.new(e).api_error render json: {error: message}, status: 422 rescue Scrivito::ApplicationError => e render json: {error: e.message}, status: e.http_code rescue Scrivito::ClientError => e render json: {error: e.message}, status: 422 end end end