Commit f3342f90 authored by Pablo Panero's avatar Pablo Panero
Browse files

views: add mapper parsing exceptions handling

parent ef58f1b7
......@@ -13,6 +13,7 @@ import ast
import copy
import os
from invenio_oauthclient.contrib import cern
from invenio_records_rest import config as irr_config
from .modules.cernsearch.permissions import (record_read_permission_factory,
......@@ -113,6 +114,11 @@ RECORDS_REST_ENDPOINTS = dict(
# App
# ===
# -*- coding: utf-8 -*-
# Copyright (C) 2019, CERN
# This software is distributed under the terms of the GNU General Public
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".
# In applying this license, CERN does not waive the privileges and immunities
# granted to it by virtue of its status as Intergovernmental Organization
# or submit itself to any jurisdiction.
from invenio_rest.errors import RESTValidationError
class InvalidRecordFormatError(RESTValidationError):
"""Invalid query syntax."""
code = 400
description = 'Invalid query syntax.'
\ No newline at end of file
......@@ -31,9 +31,18 @@ from invenio_records_rest.views import need_record_permission, pass_record
from invenio_rest import ContentNegotiatedMethodView
from invenio_search import current_search_client
from invenio_indexer.utils import default_record_to_index
from cern_search_rest_api.modules.cernsearch.errors import InvalidRecordFormatError
from import RecordCERNSearch
def elasticsearch_mapper_parsing_exception_handler(error):
"""Handle mapper parsing exceptions from ElasticSearch."""
description = 'The format of the record is invalid. {reason}.' \
return InvalidRecordFormatError(description=description).get_response()
def create_error_handlers(blueprint):
"""Create error handlers on blueprint."""
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment