summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/content.c4
-rw-r--r--content/content_protected.h8
-rw-r--r--content/handlers/css/css.c8
-rw-r--r--content/handlers/html/html.c55
-rw-r--r--content/handlers/html/html_css.c6
-rw-r--r--content/handlers/html/html_script.c6
-rw-r--r--content/handlers/image/bmp.c6
-rw-r--r--content/handlers/image/gif.c6
-rw-r--r--content/handlers/image/ico.c6
-rw-r--r--content/handlers/image/png.c8
-rw-r--r--content/handlers/image/rsvg.c12
-rw-r--r--content/handlers/image/svg.c2
-rw-r--r--content/handlers/text/textplain.c4
13 files changed, 70 insertions, 61 deletions
diff --git a/content/content.c b/content/content.c
index 367a0e5d1..bb69c766d 100644
--- a/content/content.c
+++ b/content/content.c
@@ -810,7 +810,7 @@ void content_broadcast(struct content *c, content_msg msg,
}
/* exported interface documented in content_protected.h */
-void content_broadcast_errorcode(struct content *c, nserror errorcode)
+void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
{
struct content_user *user, *next;
union content_msg_data data;
@@ -818,7 +818,7 @@ void content_broadcast_errorcode(struct content *c, nserror errorcode)
assert(c);
data.errordata.errorcode = errorcode;
- data.errordata.errormsg = NULL;
+ data.errordata.errormsg = msg;
for (user = c->user_list->next; user != 0; user = next) {
next = user->next; /* user may be destroyed during callback */
diff --git a/content/content_protected.h b/content/content_protected.h
index 0358269f2..f0a95b64d 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -174,9 +174,13 @@ void content_set_status(struct content *c, const char *status_message);
void content_broadcast(struct content *c, content_msg msg,
const union content_msg_data *data);
/**
- * Send an errorcode message to all users.
+ * Send an error message to all users.
+ *
+ * \param c The content whose users should be informed of an error
+ * \param errorcode The nserror code to send
+ * \param msg The error message to send alongside
*/
-void content_broadcast_errorcode(struct content *c, nserror errorcode);
+void content_broadcast_error(struct content *c, nserror errorcode, const char *msg);
void content_add_error(struct content *c, const char *token,
unsigned int line);
diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c
index af7aafc60..0ca47a2b6 100644
--- a/content/handlers/css/css.c
+++ b/content/handlers/css/css.c
@@ -168,7 +168,7 @@ nscss_create(const content_handler *handler,
xnsbase, charset, result->base.quirks,
nscss_content_done, result);
if (error != NSERROR_OK) {
- content_broadcast_errorcode(&result->base, NSERROR_NOMEM);
+ content_broadcast_error(&result->base, NSERROR_NOMEM, NULL);
if (charset_value != NULL)
lwc_string_unref(charset_value);
free(result);
@@ -251,7 +251,7 @@ nscss_process_data(struct content *c, const char *data, unsigned int size)
error = nscss_process_css_data(&css->data, data, size);
if (error != CSS_OK && error != CSS_NEEDDATA) {
- content_broadcast_errorcode(c, NSERROR_CSS);
+ content_broadcast_error(c, NSERROR_CSS, NULL);
}
return (error == CSS_OK || error == CSS_NEEDDATA);
@@ -285,7 +285,7 @@ bool nscss_convert(struct content *c)
error = nscss_convert_css_data(&css->data);
if (error != CSS_OK) {
- content_broadcast_errorcode(c, NSERROR_CSS);
+ content_broadcast_error(c, NSERROR_CSS, NULL);
return false;
}
@@ -480,7 +480,7 @@ void nscss_content_done(struct content_css_data *css, void *pw)
/* Retrieve the size of this sheet */
error = css_stylesheet_size(css->sheet, &size);
if (error != CSS_OK) {
- content_broadcast_errorcode(c, NSERROR_CSS);
+ content_broadcast_error(c, NSERROR_CSS, NULL);
content_set_error(c);
return;
}
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index f72284daf..ec4ff3572 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -120,9 +120,9 @@ static void html_box_convert_done(html_content *c, bool success)
html_object_free_objects(c);
if (success == false) {
- content_broadcast_errorcode(&c->base, NSERROR_BOX_CONVERT);
+ content_broadcast_error(&c->base, NSERROR_BOX_CONVERT, NULL);
} else {
- content_broadcast_errorcode(&c->base, NSERROR_STOPPED);
+ content_broadcast_error(&c->base, NSERROR_STOPPED, NULL);
}
content_set_error(&c->base);
@@ -144,7 +144,7 @@ static void html_box_convert_done(html_content *c, bool success)
* like the other error paths
*/
NSLOG(netsurf, INFO, "error retrieving html element from dom");
- content_broadcast_errorcode(&c->base, NSERROR_DOM);
+ content_broadcast_error(&c->base, NSERROR_DOM, NULL);
content_set_error(&c->base);
return;
}
@@ -154,7 +154,7 @@ static void html_box_convert_done(html_content *c, bool success)
if (err != NSERROR_OK) {
NSLOG(netsurf, INFO, "imagemap extraction failed");
html_object_free_objects(c);
- content_broadcast_errorcode(&c->base, err);
+ content_broadcast_error(&c->base, err, NULL);
content_set_error(&c->base);
dom_node_unref(html);
return;
@@ -602,7 +602,7 @@ void html_finish_conversion(html_content *htmlc)
/* Bail out if we've been aborted */
if (htmlc->aborted) {
- content_broadcast_errorcode(&htmlc->base, NSERROR_STOPPED);
+ content_broadcast_error(&htmlc->base, NSERROR_STOPPED, NULL);
content_set_error(&htmlc->base);
return;
}
@@ -626,7 +626,7 @@ void html_finish_conversion(html_content *htmlc)
/* create new css selection context */
error = html_css_new_selection_context(htmlc, &htmlc->select_ctx);
if (error != NSERROR_OK) {
- content_broadcast_errorcode(&htmlc->base, error);
+ content_broadcast_error(&htmlc->base, error, NULL);
content_set_error(&htmlc->base);
return;
}
@@ -649,7 +649,7 @@ void html_finish_conversion(html_content *htmlc)
exc = dom_document_get_document_element(htmlc->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
NSLOG(netsurf, INFO, "error retrieving html element from dom");
- content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
+ content_broadcast_error(&htmlc->base, NSERROR_DOM, NULL);
content_set_error(&htmlc->base);
return;
}
@@ -661,7 +661,7 @@ void html_finish_conversion(html_content *htmlc)
NSLOG(netsurf, INFO, "box conversion failed");
dom_node_unref(html);
html_object_free_objects(htmlc);
- content_broadcast_errorcode(&htmlc->base, error);
+ content_broadcast_error(&htmlc->base, error, NULL);
content_set_error(&htmlc->base);
return;
}
@@ -1130,14 +1130,14 @@ html_create(const content_handler *handler,
error = html_create_html_data(html, params);
if (error != NSERROR_OK) {
- content_broadcast_errorcode(&html->base, error);
+ content_broadcast_error(&html->base, error, NULL);
free(html);
return error;
}
error = html_css_new_stylesheets(html);
if (error != NSERROR_OK) {
- content_broadcast_errorcode(&html->base, error);
+ content_broadcast_error(&html->base, error, NULL);
free(html);
return error;
}
@@ -1256,7 +1256,7 @@ html_process_data(struct content *c, const char *data, unsigned int size)
/* broadcast the error if necessary */
if (err != NSERROR_OK) {
- content_broadcast_errorcode(c, err);
+ content_broadcast_error(c, err, NULL);
return false;
}
@@ -1361,8 +1361,9 @@ html_begin_conversion(html_content *htmlc)
if (error != DOM_HUBBUB_OK) {
NSLOG(netsurf, INFO, "Parsing failed");
- content_broadcast_errorcode(&htmlc->base,
- libdom_hubbub_error_to_nserror(error));
+ content_broadcast_error(&htmlc->base,
+ libdom_hubbub_error_to_nserror(error),
+ NULL);
return false;
}
@@ -1380,7 +1381,7 @@ html_begin_conversion(html_content *htmlc)
NSLOG(netsurf, INFO, "Conversion aborted (%p) (active: %u)",
htmlc, htmlc->base.active);
content_set_error(&htmlc->base);
- content_broadcast_errorcode(&htmlc->base, NSERROR_STOPPED);
+ content_broadcast_error(&htmlc->base, NSERROR_STOPPED, NULL);
return false;
}
@@ -1401,15 +1402,17 @@ html_begin_conversion(html_content *htmlc)
encoding = dom_hubbub_parser_get_encoding(htmlc->parser,
&htmlc->encoding_source);
if (encoding == NULL) {
- content_broadcast_errorcode(&htmlc->base,
- NSERROR_NOMEM);
+ content_broadcast_error(&htmlc->base,
+ NSERROR_NOMEM,
+ NULL);
return false;
}
htmlc->encoding = strdup(encoding);
if (htmlc->encoding == NULL) {
- content_broadcast_errorcode(&htmlc->base,
- NSERROR_NOMEM);
+ content_broadcast_error(&htmlc->base,
+ NSERROR_NOMEM,
+ NULL);
return false;
}
}
@@ -1418,7 +1421,7 @@ html_begin_conversion(html_content *htmlc)
exc = dom_document_get_document_element(htmlc->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
NSLOG(netsurf, INFO, "error retrieving html element from dom");
- content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
+ content_broadcast_error(&htmlc->base, NSERROR_DOM, NULL);
return false;
}
@@ -1428,7 +1431,7 @@ html_begin_conversion(html_content *htmlc)
(!dom_string_caseless_lwc_isequal(node_name,
corestring_lwc_html))) {
NSLOG(netsurf, INFO, "root element not html");
- content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
+ content_broadcast_error(&htmlc->base, NSERROR_DOM, NULL);
dom_node_unref(html);
return false;
}
@@ -1454,7 +1457,7 @@ html_begin_conversion(html_content *htmlc)
}
if (ns_error != NSERROR_OK) {
- content_broadcast_errorcode(&htmlc->base, ns_error);
+ content_broadcast_error(&htmlc->base, ns_error, NULL);
dom_node_unref(html);
return false;
@@ -1464,8 +1467,9 @@ html_begin_conversion(html_content *htmlc)
f->action = strdup(nsurl_access(action));
nsurl_unref(action);
if (f->action == NULL) {
- content_broadcast_errorcode(&htmlc->base,
- NSERROR_NOMEM);
+ content_broadcast_error(&htmlc->base,
+ NSERROR_NOMEM,
+ NULL);
dom_node_unref(html);
return false;
@@ -1475,8 +1479,9 @@ html_begin_conversion(html_content *htmlc)
if (f->document_charset == NULL) {
f->document_charset = strdup(htmlc->encoding);
if (f->document_charset == NULL) {
- content_broadcast_errorcode(&htmlc->base,
- NSERROR_NOMEM);
+ content_broadcast_error(&htmlc->base,
+ NSERROR_NOMEM,
+ NULL);
dom_node_unref(html);
return false;
}
diff --git a/content/handlers/html/html_css.c b/content/handlers/html/html_css.c
index 9d7cc7132..37a70fa70 100644
--- a/content/handlers/html/html_css.c
+++ b/content/handlers/html/html_css.c
@@ -248,7 +248,7 @@ html_create_style_element(html_content *c, dom_node *style)
(c->stylesheet_count + 1));
if (stylesheets == NULL) {
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return false;
}
@@ -272,7 +272,7 @@ static bool html_css_process_modified_style(html_content *c,
error = html_stylesheet_from_domnode(c, s->node, &sheet);
if (error != NSERROR_OK) {
NSLOG(netsurf, INFO, "Failed to update sheet");
- content_broadcast_errorcode(&c->base, error);
+ content_broadcast_error(&c->base, error, NULL);
return false;
}
@@ -480,7 +480,7 @@ bool html_css_process_link(html_content *htmlc, dom_node *node)
return true;
no_memory:
- content_broadcast_errorcode(&htmlc->base, ns_error);
+ content_broadcast_error(&htmlc->base, ns_error, NULL);
return false;
}
diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c
index 14e291ae1..6e037251c 100644
--- a/content/handlers/html/html_script.c
+++ b/content/handlers/html/html_script.c
@@ -414,7 +414,7 @@ exec_src_script(html_content *c,
/* src url */
ns_error = nsurl_join(c->base_url, dom_string_data(src), &joined);
if (ns_error != NSERROR_OK) {
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return DOM_HUBBUB_NOMEM;
}
@@ -476,7 +476,7 @@ exec_src_script(html_content *c,
nscript = html_process_new_script(c, mimetype, script_type);
if (nscript == NULL) {
nsurl_unref(joined);
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return DOM_HUBBUB_NOMEM;
}
@@ -546,7 +546,7 @@ exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype)
if (nscript == NULL) {
dom_string_unref(script);
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return DOM_HUBBUB_NOMEM;
}
diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c
index 75d8880f3..448728ede 100644
--- a/content/handlers/image/bmp.c
+++ b/content/handlers/image/bmp.c
@@ -78,7 +78,7 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
bmp->bmp = calloc(sizeof(struct bmp_image), 1);
if (bmp->bmp == NULL) {
- content_broadcast_errorcode(&bmp->base, NSERROR_NOMEM);
+ content_broadcast_error(&bmp->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
@@ -135,11 +135,11 @@ static bool nsbmp_convert(struct content *c)
case BMP_OK:
break;
case BMP_INSUFFICIENT_MEMORY:
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
case BMP_INSUFFICIENT_DATA:
case BMP_DATA_ERROR:
- content_broadcast_errorcode(c, NSERROR_BMP_ERROR);
+ content_broadcast_error(c, NSERROR_BMP_ERROR, NULL);
return false;
}
diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c
index ee85a6309..94f8d3f62 100644
--- a/content/handlers/image/gif.c
+++ b/content/handlers/image/gif.c
@@ -84,7 +84,7 @@ static nserror nsgif_create_gif_data(nsgif_content *c)
/* Initialise our data structure */
c->gif = calloc(sizeof(gif_animation), 1);
if (c->gif == NULL) {
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
gif_create(c->gif, &gif_bitmap_callbacks);
@@ -259,7 +259,7 @@ static bool nsgif_convert(struct content *c)
error = NSERROR_NOMEM;
break;
}
- content_broadcast_errorcode(c, error);
+ content_broadcast_error(c, error, NULL);
return false;
}
} while (res != GIF_OK && res != GIF_INSUFFICIENT_FRAME_DATA);
@@ -267,7 +267,7 @@ static bool nsgif_convert(struct content *c)
/* Abort on bad GIFs */
if ((gif->gif->frame_count_partial == 0) || (gif->gif->width == 0) ||
(gif->gif->height == 0)) {
- content_broadcast_errorcode(c, NSERROR_GIF_ERROR);
+ content_broadcast_error(c, NSERROR_GIF_ERROR, NULL);
return false;
}
diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c
index 467533376..1f320636b 100644
--- a/content/handlers/image/ico.c
+++ b/content/handlers/image/ico.c
@@ -75,7 +75,7 @@ static nserror nsico_create_ico_data(nsico_content *c)
c->ico = calloc(sizeof(ico_collection), 1);
if (c->ico == NULL) {
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
ico_collection_create(c->ico, &bmp_bitmap_callbacks);
@@ -134,11 +134,11 @@ static bool nsico_convert(struct content *c)
case BMP_OK:
break;
case BMP_INSUFFICIENT_MEMORY:
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
case BMP_INSUFFICIENT_DATA:
case BMP_DATA_ERROR:
- content_broadcast_errorcode(c, NSERROR_ICO_ERROR);
+ content_broadcast_error(c, NSERROR_ICO_ERROR, NULL);
return false;
}
diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c
index 841d5de52..cf8e780d6 100644
--- a/content/handlers/image/png.c
+++ b/content/handlers/image/png.c
@@ -242,7 +242,7 @@ static nserror nspng_create_png_data(nspng_content *png_c)
png_c->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if (png_c->png == NULL) {
- content_broadcast_errorcode(&png_c->base, NSERROR_NOMEM);
+ content_broadcast_error(&png_c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
@@ -252,7 +252,7 @@ static nserror nspng_create_png_data(nspng_content *png_c)
if (png_c->info == NULL) {
png_destroy_read_struct(&png_c->png, &png_c->info, 0);
- content_broadcast_errorcode(&png_c->base, NSERROR_NOMEM);
+ content_broadcast_error(&png_c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
@@ -262,7 +262,7 @@ static nserror nspng_create_png_data(nspng_content *png_c)
png_c->png = NULL;
png_c->info = NULL;
- content_broadcast_errorcode(&png_c->base, NSERROR_PNG_ERROR);
+ content_broadcast_error(&png_c->base, NSERROR_PNG_ERROR, NULL);
return NSERROR_NOMEM;
}
@@ -355,7 +355,7 @@ static bool nspng_process_data(struct content *c, const char *data,
png_c->png = NULL;
png_c->info = NULL;
- content_broadcast_errorcode(c, NSERROR_PNG_ERROR);
+ content_broadcast_error(c, NSERROR_PNG_ERROR, NULL);
ret = false;
diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c
index ee7373795..c7cb6257e 100644
--- a/content/handlers/image/rsvg.c
+++ b/content/handlers/image/rsvg.c
@@ -71,7 +71,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c)
if ((c->rsvgh = rsvg_handle_new()) == NULL) {
NSLOG(netsurf, INFO, "rsvg_handle_new() returned NULL.");
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
@@ -120,7 +120,7 @@ static bool rsvg_process_data(struct content *c, const char *data,
&err) == FALSE) {
NSLOG(netsurf, INFO,
"rsvg_handle_write returned an error: %s", err->message);
- content_broadcast_errorcode(c, NSERROR_SVG_ERROR);
+ content_broadcast_error(c, NSERROR_SVG_ERROR, NULL);
return false;
}
@@ -171,7 +171,7 @@ static bool rsvg_convert(struct content *c)
if (rsvg_handle_close(d->rsvgh, &err) == FALSE) {
NSLOG(netsurf, INFO,
"rsvg_handle_close returned an error: %s", err->message);
- content_broadcast_errorcode(c, NSERROR_SVG_ERROR);
+ content_broadcast_error(c, NSERROR_SVG_ERROR, NULL);
return false;
}
@@ -189,7 +189,7 @@ static bool rsvg_convert(struct content *c)
BITMAP_NEW)) == NULL) {
NSLOG(netsurf, INFO,
"Failed to create bitmap for rsvg render.");
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
}
@@ -200,14 +200,14 @@ static bool rsvg_convert(struct content *c)
guit->bitmap->get_rowstride(d->bitmap))) == NULL) {
NSLOG(netsurf, INFO,
"Failed to create Cairo image surface for rsvg render.");
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
}
if ((d->ct = cairo_create(d->cs)) == NULL) {
NSLOG(netsurf, INFO,
"Failed to create Cairo drawing context for rsvg render.");
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
}
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index 3f4e00c89..5124360e9 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -59,7 +59,7 @@ static nserror svg_create_svg_data(svg_content *c)
return NSERROR_OK;
no_memory:
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c
index 546301ffd..e5cd45143 100644
--- a/content/handlers/text/textplain.c
+++ b/content/handlers/text/textplain.c
@@ -182,7 +182,7 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding)
return NSERROR_OK;
no_memory:
- content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
+ content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
return NSERROR_NOMEM;
}
@@ -357,7 +357,7 @@ textplain_process_data(struct content *c, const char *data, unsigned int size)
return true;
no_memory:
- content_broadcast_errorcode(c, NSERROR_NOMEM);
+ content_broadcast_error(c, NSERROR_NOMEM, NULL);
return false;
}