Skip to content

Commit

Permalink
Logs: display the error code in places where it was missing
Browse files Browse the repository at this point in the history
It allows to understand better by reading the log what happens
  • Loading branch information
GwendalRaoul committed Jun 17, 2024
1 parent def0dd5 commit 6f9fc86
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions python_transport/wirepas_gateway/dbus/sink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ def send_data(
data,
)
if res != 0:
logging.error("Cannot send message err=%s", res)
return ReturnCode.error_from_dbus_return_code(res)
error = ReturnCode.error_from_dbus_return_code(res)
logging.error("Cannot send message %s err=%s", error.name, res)
return error
except GLib.Error as e:
logging.error("Fail to send message: %s", str(e))
return ReturnCode.error_from_dbus_exception(str(e))
error = ReturnCode.error_from_dbus_exception(str(e))
logging.error("Cannot send message %s", error.name)
return error
except OverflowError:
# It may happens as protobuf has bigger container value
logging.error("Invalid range value")
Expand Down Expand Up @@ -144,7 +147,7 @@ def read_config(self):
config["started"] = (self.proxy.StackStatus & 0x01) == 0
except GLib.Error as e:
error = ReturnCode.error_from_dbus_exception(str(e))
logging.error("Cannot get Stack state: %s", error)
logging.error("Cannot get Stack state: %s", error.name)

self._get_param(config, "node_address", "NodeAddress")
self._get_param(config, "node_role", "NodeRole")
Expand Down Expand Up @@ -207,14 +210,17 @@ def _set_param(self, dic, key, attribute):
logging.debug("key not present: %s", key)
except GLib.Error as e:
# Exception raised when setting attribute
error = ReturnCode.error_from_dbus_exception(str(e))
logging.error(
"Cannot set %s for param %s on sink %s: %s",
"Cannot set %s for param %s on sink %s: %s (%s)",
value,
key,
self.sink_id,
str(e),
error.name,
str(e)
)
return ReturnCode.error_from_dbus_exception(str(e))

return error
except OverflowError:
# It may happens as protobuf has bigger container value
logging.error(
Expand Down

0 comments on commit 6f9fc86

Please sign in to comment.