libnm-util: make property verification errors more descriptive

- fix g_set_error()/g_set_error_literal() usage
- make the error messages translatable
- use g_prefix_error() to prepend property name
This commit is contained in:
Jiří Klimeš
2013-02-07 14:49:53 +01:00
parent cc66b547cf
commit df142a5dc4
22 changed files with 756 additions and 469 deletions

View File

@@ -18,7 +18,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2012 Red Hat, Inc.
* (C) Copyright 2007 - 2013 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -26,6 +26,8 @@
#include <errno.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-vpn.h"
#include "nm-param-spec-specialized.h"
#include "nm-utils.h"
@@ -380,27 +382,30 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
if (!priv->service_type) {
g_set_error (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_MISSING_PROPERTY,
NM_SETTING_VPN_SERVICE_TYPE);
g_set_error_literal (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_VPN_SERVICE_TYPE);
return FALSE;
}
if (!strlen (priv->service_type)) {
g_set_error (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
NM_SETTING_VPN_SERVICE_TYPE);
g_set_error_literal (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_VPN_SERVICE_TYPE);
return FALSE;
}
/* default username can be NULL, but can't be zero-length */
if (priv->user_name && !strlen (priv->user_name)) {
g_set_error (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
NM_SETTING_VPN_USER_NAME);
g_set_error_literal (error,
NM_SETTING_VPN_ERROR,
NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_VPN_USER_NAME);
return FALSE;
}