def METHOD_NAME(self, request, exception):
    message = str(exception)
    code = getattr(exception, "code", None)
    locator = getattr(exception, "locator", None)
    status = 400
    if code is None:
        if isinstance(exception, MissingParameterException):
            code = "MissingParameterValue"
        elif isinstance(exception, DecodingException):
            code = "InvalidParameterValue"
        else:
            code = "InvalidRequest"
    if code in CODES_404:
        status = 404
    elif code in ("OperationNotSupported", "OptionNotSupported"):
        status = 501
    encoder = self.get_encoder(request)
    xml = encoder.serialize(
        encoder.encode_exception(message, "2.0.1", code, locator, request=request, exception=exception)
    )
    return (xml, encoder.content_type, status)