ValidationError#

exception gafaelfawr.exceptions.ValidationError(message, location, field)#

Represents an input validation error.

There is a global handler for this exception and all exceptions derived from it that returns an HTTP 422 status code with a body that’s consistent with the error messages generated internally by FastAPI. It should be used for input and parameter validation errors that cannot be caught by FastAPI for whatever reason.

Parameters:
  • message (str) – The error message (used as the msg key).

  • location (ErrorLocation) – The part of the request giving rise to the error.

  • field (str) – The field within that part of the request giving rise to the error.

Notes

The FastAPI body format supports returning multiple errors at a time as a list in the details key. The Gafaelfawr code is not currently capable of diagnosing multiple errors at once, so this functionality hasn’t been implemented.