diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-10-25 09:54:21 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-10-27 07:33:44 +0000 |
commit | 9569b99f4197ca4de57a97840a573304389fbc11 (patch) | |
tree | a1a20b85f45ca829ab8709fc0349e65198fe3487 /src | |
parent | 2de0763ac84e958756162829d7d5846e7dfefe2e (diff) |
base-bearer: normalize connection error exposed in DBus
The connection error exposed in the DBus interface should be an error
defined in the ModemManager API, and therefore it should be normalized
before being exposed.
This was already being done by limiting the exposure to MM specific
errors, but now we also try to normalize QMI or MBIM errors into MM
specific ones.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-base-bearer.c | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/mm-base-bearer.c b/src/mm-base-bearer.c index 5217b66a..c93c0504 100644 --- a/src/mm-base-bearer.c +++ b/src/mm-base-bearer.c @@ -251,6 +251,8 @@ bearer_update_connection_error (MMBaseBearer *self, g_autoptr(GVariant) tuple = NULL; if (connection_error) { + g_autoptr(GError) normalized_error = NULL; + /* Never overwrite a connection error if it's already set */ tuple = mm_gdbus_bearer_dup_connection_error (MM_GDBUS_BEARER (self)); if (tuple) @@ -259,42 +261,9 @@ bearer_update_connection_error (MMBaseBearer *self, /* * Limit the type of errors we can expose in the interface; * e.g. we don't want QMI or MBIM specific errors reported. - * - * G_IO_ERROR_CANCELLED is an exception, because we map it to - * MM_CORE_ERROR_CANCELLED implicitly when building the DBus error name. */ - if ((connection_error->domain != MM_CORE_ERROR) && - (connection_error->domain != MM_MOBILE_EQUIPMENT_ERROR) && - (connection_error->domain != MM_CONNECTION_ERROR) && - (connection_error->domain != MM_SERIAL_ERROR) && - (connection_error->domain != MM_CDMA_ACTIVATION_ERROR) && - (!g_error_matches (connection_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { - g_autoptr(GError) default_connection_error = NULL; - -#if defined WITH_QMI - if (connection_error->domain == QMI_CORE_ERROR) - mm_obj_dbg (self, "cannot set QMI core error as connection error: %s", connection_error->message); - else if (connection_error->domain == QMI_PROTOCOL_ERROR) - mm_obj_dbg (self, "cannot set QMI protocol error as connection error: %s", connection_error->message); - else -#endif -#if defined WITH_MBIM - if (connection_error->domain == MBIM_CORE_ERROR) - mm_obj_dbg (self, "cannot set MBIM core error as connection error: %s", connection_error->message); - else if (connection_error->domain == MBIM_PROTOCOL_ERROR) - mm_obj_dbg (self, "cannot set MBIM protocol error as connection error: %s", connection_error->message); - else if (connection_error->domain == MBIM_STATUS_ERROR) - mm_obj_dbg (self, "cannot set MBIM status error as connection error: %s", connection_error->message); - else -#endif - mm_obj_dbg (self, "cannot set unhandled domain error as connection error: %s", connection_error->message); - - default_connection_error = g_error_new (MM_MOBILE_EQUIPMENT_ERROR, - MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN, - "%s", connection_error->message); - tuple = mm_common_error_to_tuple (default_connection_error); - } else - tuple = mm_common_error_to_tuple (connection_error); + normalized_error = mm_normalize_error (connection_error); + tuple = mm_common_error_to_tuple (normalized_error); } mm_gdbus_bearer_set_connection_error (MM_GDBUS_BEARER (self), tuple); } |