diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-01-22 21:29:52 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-01-22 21:31:16 +0100 |
commit | 78faf438a503fe0822e64d1c4d16a3f07e2dbf5e (patch) | |
tree | 92b8a829e8994da0818c48a6e6d1bdff3870afea | |
parent | f2eb7621b43db91d5c618a3c17acea3a057c09a6 (diff) | |
download | fiv-78faf438a503fe0822e64d1c4d16a3f07e2dbf5e.tar.gz fiv-78faf438a503fe0822e64d1c4d16a3f07e2dbf5e.tar.xz fiv-78faf438a503fe0822e64d1c4d16a3f07e2dbf5e.zip |
Improve WebP error reporting
-rw-r--r-- | fiv-io.c | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -1644,6 +1644,29 @@ open_xcursor(const gchar *data, gsize len, GError **error) #endif // HAVE_XCURSOR -------------------------------------------------------- +static const char * +load_libwebp_error(VP8StatusCode err) +{ + switch (err) { + case VP8_STATUS_OUT_OF_MEMORY: + return "out of memory"; + case VP8_STATUS_INVALID_PARAM: + return "invalid parameter"; + case VP8_STATUS_BITSTREAM_ERROR: + return "bitstream error"; + case VP8_STATUS_UNSUPPORTED_FEATURE: + return "unsupported feature"; + case VP8_STATUS_SUSPENDED: + return "suspended"; + case VP8_STATUS_USER_ABORT: + return "user abort"; + case VP8_STATUS_NOT_ENOUGH_DATA: + return "not enough data"; + default: + return "general failure"; + } +} + static cairo_surface_t * load_libwebp_nonanimated(WebPDecoderConfig *config, const WebPData *wd, bool premultiply, GError **error) @@ -1675,7 +1698,8 @@ load_libwebp_nonanimated(WebPDecoderConfig *config, const WebPData *wd, VP8StatusCode err = 0; if ((err = WebPDecode(wd->bytes, wd->size, config))) { - set_error(error, "WebP decoding error"); + g_set_error(error, FIV_IO_ERROR, FIV_IO_ERROR_OPEN, + "%s: %s", "WebP decoding error", load_libwebp_error(err)); cairo_surface_destroy(surface); return NULL; } @@ -1793,7 +1817,8 @@ open_libwebp(const gchar *data, gsize len, const gchar *uri, VP8StatusCode err = 0; WebPData wd = {.bytes = (const uint8_t *) data, .size = len}; if ((err = WebPGetFeatures(wd.bytes, wd.size, &config.input))) { - set_error(error, "WebP decoding error"); + g_set_error(error, FIV_IO_ERROR, FIV_IO_ERROR_OPEN, + "%s: %s", "WebP decoding error", load_libwebp_error(err)); return NULL; } |