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

This commit is contained in:
J. Nick Koston 2023-04-29 14:33:25 -05:00 committed by GitHub
parent f38d45151a
commit b0b4134ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,12 @@ def stringify_onvif_error(error: Exception) -> str:
if isinstance(error, Fault): if isinstance(error, Fault):
message = error.message message = error.message
if error.detail: 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: if error.code:
message += f" (code:{error.code})" message += f" (code:{error.code})"
if error.subcodes: if error.subcodes: