Handle onvif errors when detail is returned as bytes (#92259)

This commit is contained in:
J. Nick Koston
2023-04-29 21:23:11 -04:00
committed by Paulus Schoutsen
parent a5241b3118
commit 6a6eba1ca3
+6 -1
View File
@@ -18,7 +18,12 @@ def stringify_onvif_error(error: Exception) -> str:
if isinstance(error, Fault):
message = error.message
if error.detail:
message += ": " + error.detail
# Detail may be a bytes object, so we need to convert it to string
if isinstance(error.detail, bytes):
detail = error.detail.decode("utf-8", "replace")
else:
detail = str(error.detail)
message += ": " + detail
if error.code:
message += f" (code:{error.code})"
if error.subcodes: