comparison src/c/urweb.c @ 1294:b4480a56cab7

Server-side 'onError'
author Adam Chlipala <adam@chlipala.net>
date Tue, 07 Sep 2010 08:28:07 -0400
parents 829da30fb808
children 929981850d9d
comparison
equal deleted inserted replaced
1293:acabf3935060 1294:b4480a56cab7
350 350
351 int uw_time = 0; 351 int uw_time = 0;
352 352
353 353
354 // Single-request state 354 // Single-request state
355
356 #define ERROR_BUF_LEN 1024
357 355
358 typedef struct regions { 356 typedef struct regions {
359 struct regions *next; 357 struct regions *next;
360 } regions; 358 } regions;
361 359
710 708
711 ctx->app->handle(ctx, path); 709 ctx->app->handle(ctx, path);
712 } 710 }
713 711
714 return r; 712 return r;
713 }
714
715 failure_kind uw_begin_onError(uw_context ctx, char *msg) {
716 int r = setjmp(ctx->jmp_buf);
717
718 if (ctx->app->on_error) {
719 if (r == 0) {
720 if (ctx->app->db_begin(ctx))
721 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN");
722
723 ctx->app->on_error(ctx, msg);
724 }
725
726 return r;
727 } else
728 uw_error(ctx, FATAL, "Tried to run nonexistent onError handler");
715 } 729 }
716 730
717 uw_Basis_client uw_Basis_self(uw_context ctx) { 731 uw_Basis_client uw_Basis_self(uw_context ctx) {
718 if (ctx->client == NULL) 732 if (ctx->client == NULL)
719 uw_error(ctx, FATAL, "Call to Basis.self() from page that has only server-side code"); 733 uw_error(ctx, FATAL, "Call to Basis.self() from page that has only server-side code");