From 8a22a7a76be8d9b439ee73383edbdf9d554bf3eb Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 18 Jun 2013 20:14:40 +0100 Subject: Exception handling changes In preparation for work on progressive loading, update the exception handling scheme slightly. Until now, exceptions (as thrown with fz_throw, and caught with fz_try/fz_catch) have merely had an informative string. They have never had anything that can be compared to see if an error is of a particular type. We now introduce error codes; when we fz_throw, we now always give an error code, and can optionally (using fz_throw_message) give both an error code and an informative string. When we fz_rethrow from within a fz_catch, both the error code and the error message is maintained. Using fz_rethrow_message we can 'improve' the error message, but the code is maintained. The error message can be read out using fz_caught_message() and the error code can be read as fz_caught(). Currently we only define a 'generic' error. This will expand in future versions to include other error types that may be tested for. --- fitz/res_shade.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fitz/res_shade.c') diff --git a/fitz/res_shade.c b/fitz/res_shade.c index 676f375c..b13dc215 100644 --- a/fitz/res_shade.c +++ b/fitz/res_shade.c @@ -914,7 +914,7 @@ fz_process_mesh(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, else if (shade->type == FZ_MESH_TYPE7) fz_process_mesh_type7(ctx, shade, ctm, &painter); else - fz_throw(ctx, "Unexpected mesh type %d\n", shade->type); + fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type); } static fz_rect * @@ -1006,7 +1006,7 @@ fz_bound_mesh(fz_context *ctx, fz_shade *shade, fz_rect *bbox) shade->type == FZ_MESH_TYPE7) fz_bound_mesh_type4567(ctx, shade, bbox); else - fz_throw(ctx, "Unexpected mesh type %d\n", shade->type); + fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type); return bbox; } -- cgit v1.2.3