diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-10-26 10:54:17 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2023-10-27 11:34:26 +0200 |
commit | 1f9a04268f6de7e9aa11073f0bf363aadc2ca29b (patch) | |
tree | 64519e385d67a5a9353681ddd39b15e979d5ead0 /src/mm-iface-modem-time.c | |
parent | 9569b99f4197ca4de57a97840a573304389fbc11 (diff) |
core: ensure all errors returned in DBus operations are normalized
We want to ensure that all errors reported via DBus operations are
normalized to MM-specific errors.
We don't want to return QMI or MBIM specific errors, as those are
protocol specific and we don't want DBus clients to need to rely on
knowing which is the protocol in use by the device.
Diffstat (limited to 'src/mm-iface-modem-time.c')
-rw-r--r-- | src/mm-iface-modem-time.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/mm-iface-modem-time.c b/src/mm-iface-modem-time.c index af631bcc..ac7b1d2a 100644 --- a/src/mm-iface-modem-time.c +++ b/src/mm-iface-modem-time.c @@ -19,6 +19,7 @@ #include "mm-iface-modem.h" #include "mm-iface-modem-time.h" +#include "mm-error-helpers.h" #include "mm-log-object.h" #define SUPPORT_CHECKED_TAG "time-support-checked-tag" @@ -64,7 +65,7 @@ load_network_time_ready (MMIfaceModemTime *self, time_str = MM_IFACE_MODEM_TIME_GET_INTERFACE (self)->load_network_time_finish (self, res, &error); if (error) - g_dbus_method_invocation_take_error (ctx->invocation, error); + mm_dbus_method_invocation_take_error (ctx->invocation, error); else mm_gdbus_modem_time_complete_get_network_time (ctx->skeleton, ctx->invocation, time_str); g_free (time_str); @@ -80,7 +81,7 @@ handle_get_network_time_auth_ready (MMBaseModem *self, GError *error = NULL; if (!mm_base_modem_authorize_finish (self, res, &error)) { - g_dbus_method_invocation_take_error (ctx->invocation, error); + mm_dbus_method_invocation_take_error (ctx->invocation, error); handle_get_network_time_context_free (ctx); return; } @@ -91,22 +92,16 @@ handle_get_network_time_auth_ready (MMBaseModem *self, NULL); /* If we're not yet registered, we cannot get the network time */ if (state < MM_MODEM_STATE_REGISTERED) { - g_dbus_method_invocation_return_error (ctx->invocation, - MM_CORE_ERROR, - MM_CORE_ERROR_WRONG_STATE, - "Cannot load network time: " - "not registered yet"); + mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE, + "Cannot load network time: not registered yet"); handle_get_network_time_context_free (ctx); return; } if (!MM_IFACE_MODEM_TIME_GET_INTERFACE (self)->load_network_time || !MM_IFACE_MODEM_TIME_GET_INTERFACE (self)->load_network_time_finish) { - g_dbus_method_invocation_return_error (ctx->invocation, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED, - "Cannot load network time: " - "operation not supported"); + mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, + "Cannot load network time: operation not supported"); handle_get_network_time_context_free (ctx); return; } |