summaryrefslogtreecommitdiff
path: root/xps/xps_doc.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2011-10-04 18:44:19 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-10-04 18:44:19 +0100
commitd208be26537db558edb70236ae517cea31b7ebab (patch)
tree57da95b97e354a53bd4517a42010e90968f007d9 /xps/xps_doc.c
parentba46cad4b09bb957085900a203206c8fa5868cd4 (diff)
downloadmupdf-d208be26537db558edb70236ae517cea31b7ebab.tar.xz
Move to exception handling rather than error passing throughout.
This frees us from passing errors back everywhere, and hence enables us to pass results back as return values. Rather than having to explicitly check for errors everywhere and bubble them, we now allow exception handling to do the work for us; the downside to this is that we no longer emit as much debugging information as we did before (though this could be put back in). For now, the debugging information we have lost has been retained in comments with 'RJW:' at the start. This code needs fuller testing, but is being committed as a work in progress.
Diffstat (limited to 'xps/xps_doc.c')
-rw-r--r--xps/xps_doc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/xps/xps_doc.c b/xps/xps_doc.c
index 378006e3..dca1868c 100644
--- a/xps/xps_doc.c
+++ b/xps/xps_doc.c
@@ -305,11 +305,10 @@ xps_load_fixed_page(xps_document *doc, xps_page *page)
return 0;
}
-int
-xps_load_page(xps_page **pagep, xps_document *doc, int number)
+xps_page *
+xps_load_page(xps_document *doc, int number)
{
xps_page *page;
- int code;
int n = 0;
for (page = doc->first_page; page; page = page->next)
@@ -318,17 +317,16 @@ xps_load_page(xps_page **pagep, xps_document *doc, int number)
{
if (!page->root)
{
- code = xps_load_fixed_page(doc, page);
- if (code)
- return fz_error_note(code, "cannot load page %d", number + 1);
+ xps_load_fixed_page(doc, page);
+ /* RJW: "cannot load page %d", number + 1 */
}
- *pagep = page;
- return fz_okay;
+ return page;
}
n ++;
}
- return fz_error_make("cannot find page %d", number + 1);
+ fz_throw(doc->ctx, "cannot find page %d", number + 1);
+ return NULL; /* Stupid MSVC */
}
void