# frozen_string_literal: true require "minato_logger" module MinatoErrorHandler module ErrorHandler extend ActiveSupport::Concern included do rescue_from StandardError, with: :handle end private def handle(exception) error = MinatoErrorHandler::MinatoError.from_error(exception) report_error(error) render json: { errors: [error.to_json] }, status: error.status_code end def report_error(error) logger = MinatoLogger::Logger.new logger.error(error.to_json) end end end