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. --- apps/pdfclean.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/pdfclean.c') diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 3c1e810e..c437b819 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -212,7 +212,7 @@ int pdfclean_main(int argc, char **argv) xref = pdf_open_document_no_run(ctx, infile); if (pdf_needs_password(xref)) if (!pdf_authenticate_password(xref, password)) - fz_throw(ctx, "cannot authenticate password: %s", infile); + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", infile); /* Only retain the specified subset of the pages */ if (subset) -- cgit v1.2.3