swh.deposit.errors module#

Module in charge of providing the standard sword errors

exception swh.deposit.errors.ParserError[source]#

Bases: ValueError

Specific parsing error detected when parsing the xml metadata input

swh.deposit.errors.make_error_dict(key, summary=None, verbose_description=None)[source]#

Utility function to factorize error message dictionary.

Parameters:
  • key (str) – Error status key referenced in swh.deposit.errors module

  • summary (str/None) – Error message clarifying the status

  • verbose_description (str/None) – A more verbose description or work around a potential problem.

Returns:

Dictionary with key ‘error’ detailing the ‘status’ and associated ‘message’

swh.deposit.errors.make_error_response_from_dict(req, error)[source]#

Utility function to return an http response with error detail.

Parameters:
  • req (Request) – original request

  • error (dict) – Error described as dict, typically generated

  • function. (from the make_error_dict)

Returns:

HttpResponse with detailed error.

swh.deposit.errors.make_error_response(req, key, summary=None, verbose_description=None)[source]#

Utility function to create an http response with detailed error.

Parameters:
  • req (Request) – original request

  • key (str) – Error status key referenced in swh.deposit.errors module

  • summary (str) – Error message clarifying the status

  • verbose_description (str / None) – A more verbose description or work around a potential problem.

Returns:

Dictionary with key ‘error’ detailing the ‘status’ and associated ‘message’

exception swh.deposit.errors.DepositError(key, summary, verbose_description=None)[source]#

Bases: ValueError

Represents an error that should be reported to the client

to_dict()[source]#
class swh.deposit.errors.DepositErrorMiddleware(get_response)[source]#

Bases: object

A Django middleware that catches DepositError and returns a proper error response.

process_exception(request, exception)[source]#