def METHOD_NAME(*args, **kwargs):
    error = None
    try:
        return f(*args, **kwargs)
    except Exception as e:
        error = force_str(str(e)) + " " + force_str(traceback.format_exc())
    try:
        return encode({"result": None, "error": error, "metrics": None})
    except (ValueError, TypeError) as e:
        try:
            # Encoding error, try to send the exception instead
            return encode(
                {
                    "result": None,
                    "error": force_str(str(e)) + " " + force_str(traceback.format_exc()),
                    "metrics": None,
                    "encoding_error": True,
                }
            )
        except Exception:
            return b"{}"