in elasticsearch/exceptions.py [0:0]
def __str__(self) -> str:
cause = ""
try:
if self.body and isinstance(self.body, dict) and "error" in self.body:
if isinstance(self.body["error"], dict):
root_cause = self.body["error"]["root_cause"][0]
caused_by = self.body["error"].get("caused_by", {})
cause = ", ".join(
filter(
None,
[
repr(root_cause["reason"]),
root_cause.get("resource.id"),
root_cause.get("resource.type"),
caused_by.get("reason"),
],
)
)
else:
cause = repr(self.body["error"])
except LookupError:
pass
msg = ", ".join(filter(None, [str(self.status_code), repr(self.error), cause]))
return f"{self.__class__.__name__}({msg})"