aboutsummaryrefslogtreecommitdiff
path: root/src/kike.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-15 22:54:39 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-16 00:53:59 +0200
commit2921eed702d994352c5afccc31e32bd3f1682b6b (patch)
tree044ef2300088f723d627ab529d7c052a84f74b48 /src/kike.c
parenta2a979ea2e7ded82cbe4d4cab5da6e613d74a9d0 (diff)
downloadxK-2921eed702d994352c5afccc31e32bd3f1682b6b.tar.gz
xK-2921eed702d994352c5afccc31e32bd3f1682b6b.tar.xz
xK-2921eed702d994352c5afccc31e32bd3f1682b6b.zip
Rip out error codes
As it turns out, they're rather annoying to maintain, and we don't even need them. They also clutter the code unnecessarily in their current form. If it ever comes to having to have them, let's make another version of error_set(), maybe error_set_with_code(), that makes it possible to also set an integer within `struct error'. The only problem with the above solution is when we aggregate errors from multiple functions (be it by calling one after another, or through nesting of functions that may return an error). But let's care about that when the time comes for it.
Diffstat (limited to 'src/kike.c')
-rw-r--r--src/kike.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/kike.c b/src/kike.c
index 07ec21f..4e49ffe 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -425,15 +425,6 @@ server_context_free (struct server_context *self)
// --- Main program ------------------------------------------------------------
-static size_t network_error_domain_tag;
-#define NETWORK_ERROR (error_resolve_domain (&network_error_domain_tag))
-
-enum
-{
- NETWORK_ERROR_INVALID_CONFIGURATION,
- NETWORK_ERROR_FAILED
-};
-
static void
client_kill (struct client *c, const char *reason)
{
@@ -1140,8 +1131,7 @@ irc_initialize_catalog (struct server_context *ctx, struct error **e)
char *path = resolve_config_filename (catalog);
if (!path)
{
- error_set (e, IO_ERROR, IO_ERROR_FAILED, "%s: %s",
- "cannot open file", catalog);
+ error_set (e, "%s: %s", "cannot open file", catalog);
return false;
}
ctx->catalog = catopen (path, NL_CAT_LOCALE);
@@ -1149,7 +1139,7 @@ irc_initialize_catalog (struct server_context *ctx, struct error **e)
if (ctx->catalog == (nl_catd) -1)
{
- error_set (e, IO_ERROR, IO_ERROR_FAILED, "%s: %s",
+ error_set (e, "%s: %s",
"failed reading the message catalog file", strerror (errno));
return false;
}
@@ -1167,8 +1157,7 @@ irc_initialize_motd (struct server_context *ctx, struct error **e)
char *path = resolve_config_filename (motd);
if (!path)
{
- error_set (e, IO_ERROR, IO_ERROR_FAILED, "%s: %s",
- "cannot open file", motd);
+ error_set (e, "%s: %s", "cannot open file", motd);
return false;
}
FILE *fp = fopen (path, "r");
@@ -1176,7 +1165,7 @@ irc_initialize_motd (struct server_context *ctx, struct error **e)
if (!fp)
{
- error_set (e, IO_ERROR, IO_ERROR_FAILED, "%s: %s",
+ error_set (e, "%s: %s",
"failed reading the MOTD file", strerror (errno));
return false;
}
@@ -1201,9 +1190,8 @@ irc_initialize_server_name (struct server_context *ctx, struct error **e)
res = irc_validate_hostname (server_name);
if (res != VALIDATION_OK)
{
- error_set (e, NETWORK_ERROR, NETWORK_ERROR_INVALID_CONFIGURATION,
- "invalid configuration value for `%s': %s", "server_name",
- irc_validate_to_str (res));
+ error_set (e, "invalid configuration value for `%s': %s",
+ "server_name", irc_validate_to_str (res));
return false;
}
ctx->server_name = xstrdup (server_name);
@@ -1213,14 +1201,14 @@ irc_initialize_server_name (struct server_context *ctx, struct error **e)
char hostname[HOST_NAME_MAX];
if (gethostname (hostname, sizeof hostname))
{
- error_set (e, NETWORK_ERROR, NETWORK_ERROR_INVALID_CONFIGURATION,
- "%s: %s", "getting the hostname failed", strerror (errno));
+ error_set (e, "%s: %s",
+ "getting the hostname failed", strerror (errno));
return false;
}
res = irc_validate_hostname (hostname);
if (res != VALIDATION_OK)
{
- error_set (e, NETWORK_ERROR, NETWORK_ERROR_INVALID_CONFIGURATION,
+ error_set (e,
"`%s' is not set and the hostname (`%s') cannot be used: %s",
"server_name", hostname, irc_validate_to_str (res));
return false;
@@ -1246,7 +1234,7 @@ irc_listen (struct server_context *ctx, struct error **e)
int err = getaddrinfo (bind_host, bind_port, &gai_hints, &gai_result);
if (err)
{
- error_set (e, NETWORK_ERROR, NETWORK_ERROR_FAILED, "%s: %s: %s",
+ error_set (e, "%s: %s: %s",
"network setup failed", "getaddrinfo", gai_strerror (err));
return false;
}
@@ -1291,8 +1279,7 @@ irc_listen (struct server_context *ctx, struct error **e)
if (!gai_iter)
{
- error_set (e, NETWORK_ERROR, NETWORK_ERROR_FAILED,
- "network setup failed");
+ error_set (e, "network setup failed");
return false;
}