summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/errors.h4
-rw-r--r--utils/messages.c96
-rw-r--r--utils/messages.h9
3 files changed, 109 insertions, 0 deletions
diff --git a/utils/errors.h b/utils/errors.h
index 9ad613da6..7fcb5bd09 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -61,6 +61,10 @@ typedef enum {
NSERROR_DOM, /**< DOM call returned error */
+ NSERROR_CSS, /**< CSS call returned error */
+
+ NSERROR_CSS_BASE, /**< CSS base sheet failed */
+
NSERROR_BAD_URL /**< Bad URL */
} nserror;
diff --git a/utils/messages.c b/utils/messages.c
index 5b62912a6..8ae616b86 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -200,3 +200,99 @@ const char *messages_get(const char *key)
{
return messages_get_ctx(key, messages_hash);
}
+
+
+/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+
+const char *messages_get_errorcode(nserror code)
+{
+ switch (code) {
+ case NSERROR_OK:
+ /**< No error */
+ return messages_get_ctx("OK", messages_hash);
+
+ case NSERROR_NOMEM:
+ /**< Memory exhaustion */
+ return messages_get_ctx("NoMemory", messages_hash);
+
+ case NSERROR_NO_FETCH_HANDLER:
+ /**< No fetch handler for URL scheme */
+ return messages_get_ctx("NoHandler", messages_hash);
+
+ case NSERROR_NOT_FOUND:
+ /**< Requested item not found */
+ return messages_get_ctx("NotFound", messages_hash);
+
+ case NSERROR_SAVE_FAILED:
+ /**< Failed to save data */
+ return messages_get_ctx("SaveFailed", messages_hash);
+
+ case NSERROR_CLONE_FAILED:
+ /**< Failed to clone handle */
+ return messages_get_ctx("CloneFailed", messages_hash);
+
+ case NSERROR_INIT_FAILED:
+ /**< Initialisation failed */
+ return messages_get_ctx("InitFailed", messages_hash);
+
+ case NSERROR_MNG_ERROR:
+ /**< An MNG error occurred */
+ return messages_get_ctx("MNGError", messages_hash);
+
+ case NSERROR_BAD_ENCODING:
+ /**< The character set is unknown */
+ return messages_get_ctx("BadEncoding", messages_hash);
+
+ case NSERROR_NEED_DATA:
+ /**< More data needed */
+ return messages_get_ctx("NeedData", messages_hash);
+
+ case NSERROR_ENCODING_CHANGE:
+ /**< The character set encoding change was unhandled */
+ return messages_get_ctx("EncodingChanged", messages_hash);
+
+ case NSERROR_BAD_PARAMETER:
+ /**< Bad Parameter */
+ return messages_get_ctx("BadParameter", messages_hash);
+
+ case NSERROR_INVALID:
+ /**< Invalid data */
+ return messages_get_ctx("Invalid", messages_hash);
+
+ case NSERROR_BOX_CONVERT:
+ /**< Box conversion failed */
+ return messages_get_ctx("BoxConvert", messages_hash);
+
+ case NSERROR_STOPPED:
+ /**< Content conversion stopped */
+ return messages_get_ctx("Stopped", messages_hash);
+
+ case NSERROR_DOM:
+ /**< DOM call returned error */
+ return messages_get_ctx("ParsingFail", messages_hash);
+
+ case NSERROR_CSS:
+ /**< CSS call returned error */
+ return messages_get_ctx("CSSGeneric", messages_hash);
+
+ case NSERROR_CSS_BASE:
+ /**< CSS base sheet failed */
+ return messages_get_ctx("CSSBase", messages_hash);
+
+ case NSERROR_BAD_URL:
+ /**< Bad URL */
+ return messages_get_ctx("BadURL", messages_hash);
+
+ default:
+ case NSERROR_UNKNOWN:
+ break;
+ }
+
+ /**< Unknown error */
+ return messages_get_ctx("Unknown", messages_hash);
+}
diff --git a/utils/messages.h b/utils/messages.h
index 2b78d07ee..81c380515 100644
--- a/utils/messages.h
+++ b/utils/messages.h
@@ -33,6 +33,7 @@
#ifndef _NETSURF_UTILS_MESSAGES_H_
#define _NETSURF_UTILS_MESSAGES_H_
+#include "utils/errors.h"
#include "utils/hashtable.h"
void messages_load(const char *path);
@@ -41,6 +42,14 @@ const char *messages_get_ctx(const char *key, struct hash_table *ctx);
const char *messages_get(const char *key);
/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+const char *messages_get_errorcode(nserror code);
+
+/**
* Formatted message from a key in the global message hash.
*
* \param key key of message