src/pds_doi_service/api/util.py
def format_exceptions(exceptions):
    """
    Formats a listing of exceptions into a JSON-friendly representation suitable
    for return in an HTTP response.

    Parameters
    ----------
    exceptions : Exception or list or tuple of Exception
        The listing of exceptions to format. A single Exception instance may
        be provided as well.

    Returns
    -------
    formatted_exceptions : dict
        The provided exceptions in the following format:

        ```python
        {
            'errors': [
                {
                    'name': <Exception class name>,
                    'message': <Exception message>
                },
                ...
            ]
        }
        ```

    """
    # Check if we were given a single exception, rather than a listing
    if not isinstance(exceptions, Iterable):
        exceptions = [exceptions]

    return {"errors": [{"name": type(exception).__name__, "message": str(exception)} for exception in exceptions]}

    Formats a listing of exceptions into a JSON-friendly representation suitable
    for return in an HTTP response.

    Parameters
    ----------
    exceptions : Exception or list or tuple of Exception
        The listing of exceptions to format. A single Exception instance may
        be provided as well.

    Returns
    -------
    formatted_exceptions : dict
        The provided exceptions in the following format:

        ```python
        {
            'errors': [
                {
                    'name': <Exception class name>,
                    'message': <Exception message>
                },
                ...
            ]
        }
        ```

    
Formats a listing of exceptions into a JSON-friendly representation suitable
for return in an HTTP response.

Parameters

exceptions : Exception or list or tuple of Exception
The listing of exceptions to format. A single Exception instance may
be provided as well.

Returns

formatted_exceptions : dict
The provided exceptions in the following format.


Formats a listing of exceptions into a JSON - friendly representation suitable for return in an HTTP response . Parameters exceptions : Exception or list or tuple of Exception The listing of exceptions to format . A single Exception instance may be provided as well . Returns formatted_exceptions : dict The provided exceptions in the following format .
def format_exceptions(exceptions):
    if not isinstance(exceptions, Iterable):
        exceptions = [exceptions]
    return {"errors": [{"name": type(exception).__name__, "message": str(exception)} for exception in exceptions]}
def format_exceptions ( exceptions ) : if not isinstance ( exceptions , Iterable ) : exceptions = [ exceptions ] return { "errors" : [ { "name" : type ( exception ) . __name__ , "message" : str ( exception ) } for exception in exceptions ] }
Formats a listing of exceptions into a JSON-friendly representation suitable
for return in an HTTP response.
Formats a listing of exceptions into a JSON - friendly representation suitable for return in an HTTP response .
"""
    Formats a listing of exceptions into a JSON-friendly representation suitable
    for return in an HTTP response.

    Parameters
    ----------
    exceptions : Exception or list or tuple of Exception
        The listing of exceptions to format. A single Exception instance may
        be provided as well.

    Returns
    -------
    formatted_exceptions : dict
        The provided exceptions in the following format:

        ```python
        {
            'errors': [
                {
                    'name': <Exception class name>,
                    'message': <Exception message>
                },
                ...
            ]
        }
        ```

    """ # Check if we were given a single exception, rather than a listing
exceptions