summaryrefslogtreecommitdiff
path: root/fitz/base_error.c
diff options
context:
space:
mode:
Diffstat (limited to 'fitz/base_error.c')
-rw-r--r--fitz/base_error.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/fitz/base_error.c b/fitz/base_error.c
index 31d285fe..f16dd4d0 100644
--- a/fitz/base_error.c
+++ b/fitz/base_error.c
@@ -89,6 +89,7 @@ int fz_push_try(fz_error_context *ex)
{
assert(ex);
ex->top++;
+ ex->errcode = FZ_ERROR_NONE;
/* Normal case, get out of here quick */
if (ex->top < nelem(ex->stack)-1)
return 1; /* We exit here, and the setjmp sets the code to 0 */
@@ -104,16 +105,24 @@ int fz_push_try(fz_error_context *ex)
return 0;
}
-const char *fz_caught(fz_context *ctx)
+int fz_caught(fz_context *ctx)
+{
+ assert(ctx);
+ assert(ctx->error);
+ return ctx->error->errcode;
+}
+
+const char *fz_caught_message(fz_context *ctx)
{
assert(ctx);
assert(ctx->error);
return ctx->error->message;
}
-void fz_throw(fz_context *ctx, const char *fmt, ...)
+void fz_throw(fz_context *ctx, int code, const char *fmt, ...)
{
va_list args;
+ ctx->error->errcode = code;
va_start(args, fmt);
vsnprintf(ctx->error->message, sizeof ctx->error->message, fmt, args);
va_end(args);
@@ -129,3 +138,17 @@ void fz_rethrow(fz_context *ctx)
{
throw(ctx->error);
}
+
+void fz_rethrow_message(fz_context *ctx, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(ctx->error->message, sizeof ctx->error->message, fmt, args);
+ va_end(args);
+
+ fz_flush_warnings(ctx);
+ fprintf(stderr, "error: %s\n", ctx->error->message);
+ LOGE("error: %s\n", ctx->error->message);
+
+ throw(ctx->error);
+}