def resolwe_exception_handler(exc, context):
    """Handle exceptions raised in API and make them nicer.

    To enable this, you have to add it to the settings:

        .. code:: python

            REST_FRAMEWORK = {
                'EXCEPTION_HANDLER': 'resolwe.flow.utils.exceptions.resolwe_exception_handler',
            }

    """
    response = exception_handler(exc, context)

    if isinstance(exc, ValidationError):
        if response is None:
            response = Response({})
        response.status_code = 400
        response.data['error'] = exc.message

    return response
Handle exceptions raised in API and make them nicer.

    To enable this, you have to add it to the settings:

        .. code:: python

            REST_FRAMEWORK = {
                'EXCEPTION_HANDLER': 'resolwe.flow.utils.exceptions.resolwe_exception_handler',
            }