summaryrefslogtreecommitdiff
path: root/libmm-glib/mm-simple-connect-properties.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-01-06 14:46:36 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-01-06 14:46:36 +0100
commitbaa68f5a4aead320ed2c1a7debfc624cdd2a5e48 (patch)
tree7c39fc94a9369b91b5d29ec2bbc54bd80c143c5b /libmm-glib/mm-simple-connect-properties.c
parent15e8a78a15e458efae781d4905134e07043aad25 (diff)
downloadModemManager-baa68f5a4aead320ed2c1a7debfc624cdd2a5e48.tar.gz
libmm-glib,simple-connect-properties: cleaner error handling
If processing a key-value pair as a bearer property fails, we need to know if it failed due to the key being unknown or due to some other reason (e.g. failure parsing value of a known key). We'll only try with the Simple.Connect properties if the key is reported as unknown in the bearer properties. This will help us better identify errors if e.g. an invalid value is given to a known key. E.g. "yes" was invalid for allow-roaming here: daemon.notice netifd: wan (30476): simple connect=apn=internet,ip-type=ipv4,allow-roaming=yes daemon.notice netifd: wan (30476): Error parsing connect string: 'Invalid properties string, unexpected key 'allow-roaming''
Diffstat (limited to 'libmm-glib/mm-simple-connect-properties.c')
-rw-r--r--libmm-glib/mm-simple-connect-properties.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libmm-glib/mm-simple-connect-properties.c b/libmm-glib/mm-simple-connect-properties.c
index f8649b55e..5b9af11a9 100644
--- a/libmm-glib/mm-simple-connect-properties.c
+++ b/libmm-glib/mm-simple-connect-properties.c
@@ -490,20 +490,32 @@ key_value_foreach (const gchar *key,
const gchar *value,
ParseKeyValueContext *ctx)
{
+ GError *inner_error = NULL;
+
/* First, check if we can consume this as bearer properties */
if (mm_bearer_properties_consume_string (ctx->self->priv->bearer_properties,
key, value,
- NULL))
+ &inner_error))
return TRUE;
+ /* Unknown keys are reported as unsupported. Any other error is right away
+ * fatal (e.g. an invalid value given to a known bearer property) */
+ if (!g_error_matches (inner_error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED)) {
+ ctx->error = inner_error;
+ return FALSE;
+ }
+
+ /* On unsupported errors, try with the Simple.Connect specific properties */
+ g_clear_error (&inner_error);
+
if (g_str_equal (key, PROPERTY_PIN))
mm_simple_connect_properties_set_pin (ctx->self, value);
else if (g_str_equal (key, PROPERTY_OPERATOR_ID))
mm_simple_connect_properties_set_operator_id (ctx->self, value);
else {
ctx->error = g_error_new (MM_CORE_ERROR,
- MM_CORE_ERROR_INVALID_ARGS,
- "Invalid properties string, unexpected key '%s'",
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Invalid properties string, unsupported key '%s'",
key);
}