summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-03-11 01:44:12 +0100
committerTor Andersson <tor@ghostscript.com>2009-03-11 01:44:12 +0100
commit5aaff8260abdaefdbf7a64d3e66b1928dfe5d726 (patch)
treefebd7d6938978dac98dc0f7e6e501df46b6e3754 /apps
parent5733fd611487151f33338b1ecda4819c26ccd25f (diff)
downloadmupdf-5aaff8260abdaefdbf7a64d3e66b1928dfe5d726.tar.xz
Add fz_catch function, and cause the throw/rethrow/catch functions to print the errors immediately.
Diffstat (limited to 'apps')
-rw-r--r--apps/common/pdfapp.c15
-rw-r--r--apps/pdfclean.c9
-rw-r--r--apps/pdfdraw.c11
-rw-r--r--apps/pdfinfo.c17
-rw-r--r--apps/pdfshow.c9
-rw-r--r--apps/unix/x11pdf.c2
6 files changed, 19 insertions, 44 deletions
diff --git a/apps/common/pdfapp.c b/apps/common/pdfapp.c
index b01bd485..b3507097 100644
--- a/apps/common/pdfapp.c
+++ b/apps/common/pdfapp.c
@@ -83,16 +83,11 @@ void pdfapp_open(pdfapp_t *app, char *filename)
error = pdf_loadxref(app->xref, filename);
if (error)
{
- if (!strncmp(error->msg, "ioerror", 7))
- pdfapp_error(app, error);
- pdfapp_warn(app,
- "There was a problem with file \"%s\".\n"
- "It may be corrupted or generated by faulty software.\n\n"
- "%s\n\nTrying to continue anyway...",
- filename, error->msg);
- error = pdf_repairxref(app->xref, filename);
- if (error)
- pdfapp_error(app, error);
+ fz_catch(error, "trying to repair");
+ pdfapp_warn(app, "There was a problem with file \"%s\".\nIt may be corrupted or generated by faulty software.\nTrying to repair the file.", filename);
+ error = pdf_repairxref(app->xref, filename);
+ if (error)
+ pdfapp_error(app, error);
}
/*
diff --git a/apps/pdfclean.c b/apps/pdfclean.c
index 7a8cc0fc..58fc9b68 100644
--- a/apps/pdfclean.c
+++ b/apps/pdfclean.c
@@ -26,10 +26,7 @@ int doexpand = 0;
void die(fz_error *eo)
{
- fflush(stdout);
- fz_printerror(eo);
- fz_droperror(eo);
- fflush(stderr);
+ fz_catch(eo, "aborting");
exit(1);
}
@@ -45,9 +42,7 @@ void openxref(char *filename, char *password)
error = pdf_loadxref(xref, filename);
if (error)
{
- fz_printerror(error);
- fz_droperror(error);
- fz_warn("trying to repair");
+ fz_catch(error, "trying to repair");
error = pdf_repairxref(xref, filename);
if (error)
die(error);
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c
index 53df42c8..cc7ce53e 100644
--- a/apps/pdfdraw.c
+++ b/apps/pdfdraw.c
@@ -23,13 +23,10 @@ pdf_pagetree *pagetree = nil;
void die(fz_error *eo)
{
- fflush(stdout);
- fz_printerror(eo);
- fz_droperror(eo);
- fflush(stderr);
+ fz_catch(eo, "aborting");
if (drawgc)
fz_droprenderer(drawgc);
- abort();
+ exit(1);
}
void openxref(char *filename, char *password)
@@ -50,9 +47,7 @@ void openxref(char *filename, char *password)
error = pdf_loadxref(xref, filename);
if (error)
{
- fz_printerror(error);
- fz_droperror(error);
- fz_warn("trying to repair");
+ fz_catch(error, "trying to repair");
error = pdf_repairxref(xref, filename);
if (error)
die(error);
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c
index 374b39c6..c785391d 100644
--- a/apps/pdfinfo.c
+++ b/apps/pdfinfo.c
@@ -30,14 +30,11 @@ pdf_pagetree *srcpages = nil;
void die(fz_error *eo)
{
- fflush(stdout);
- fz_printerror(eo);
- fz_droperror(eo);
- fflush(stderr);
- if (drawgc)
- fz_droprenderer(drawgc);
- closesrc();
- abort();
+ fz_catch(eo, "aborting");
+ if (drawgc)
+ fz_droprenderer(drawgc);
+ closesrc();
+ exit(-1);
}
void closesrc(void)
@@ -78,9 +75,7 @@ void opensrc(char *filename, char *password, int loadpages)
error = pdf_loadxref(src, filename);
if (error)
{
- fz_printerror(error);
- fz_droperror(error);
- fz_warn("trying to repair");
+ fz_catch(error, "trying to repair");
error = pdf_repairxref(src, filename);
if (error)
die(error);
diff --git a/apps/pdfshow.c b/apps/pdfshow.c
index b3239978..4d59c590 100644
--- a/apps/pdfshow.c
+++ b/apps/pdfshow.c
@@ -9,10 +9,7 @@ pdf_xref *xref = NULL;
void die(fz_error *eo)
{
- fflush(stdout);
- fz_printerror(eo);
- fz_droperror(eo);
- fflush(stderr);
+ fz_catch(eo, "aborting");
exit(1);
}
@@ -28,9 +25,7 @@ void openxref(char *filename, char *password)
error = pdf_loadxref(xref, filename);
if (error)
{
- fz_printerror(error);
- fz_droperror(error);
- fz_warn("trying to repair");
+ fz_catch(error, "trying to repair");
error = pdf_repairxref(xref, filename);
if (error)
die(error);
diff --git a/apps/unix/x11pdf.c b/apps/unix/x11pdf.c
index 0b1ff37c..18507f62 100644
--- a/apps/unix/x11pdf.c
+++ b/apps/unix/x11pdf.c
@@ -84,7 +84,7 @@ void winwarn(pdfapp_t *app, char *msg)
void winerror(pdfapp_t *app, fz_error *error)
{
- fz_printerror(error);
+ fz_catch(error, "aborting");
exit(1);
}