Commit b7e19a46 authored by Niels Möller's avatar Niels Möller
Browse files

* src/exception.h (exception_handler): Added context attribute.

(HANDLER_CONTEXT): New macro.

* src/exception.c (make_exception_handler): Added context argument.
(make_report_exception_handler): -"-
(exception_raise): New function.

Rev: src/exception.c:1.9
Rev: src/exception.h:1.11
parent 39a4bb0d
......@@ -71,12 +71,14 @@ STATIC_EXCEPTION_HANDLER(do_ignore_exception_handler, NULL);
struct exception_handler *
make_exception_handler(void (*raise)(struct exception_handler *s,
const struct exception *x),
struct exception_handler *parent)
struct exception_handler *parent,
const char *context)
{
NEW(exception_handler, self);
self->raise = raise;
self->parent = parent;
self->context = context;
return self;
}
......@@ -105,11 +107,14 @@ do_report_exception_handler(struct exception_handler *s,
struct exception_handler *
make_report_exception_handler(UINT32 mask, UINT32 value,
const char *prefix,
struct exception_handler *parent)
struct exception_handler *parent,
const char *context)
{
NEW(report_exception_handler, self);
self->super.raise = do_report_exception_handler;
self->super.parent = parent;
self->super.context = context;
self->mask = mask;
self->value = value;
self->prefix = prefix;
......@@ -156,3 +161,11 @@ make_protocol_exception(UINT32 reason, const char *msg)
return &self->super;
}
void exception_raise(struct exception_handler *h,
const struct exception *e)
{
trace ("Raising exception %z (type %d), using handler installed by %z\n",
e->msg, e->type, h->context);
h->raise(h, e);
}
......@@ -46,13 +46,26 @@
(name exception_handler)
(vars
(raise method void "const struct exception *")
(parent object exception_handler)))
(parent object exception_handler)
; Provide some context for debugging unhandled exceptions
(context . "const char *")))
*/
#define EXCEPTION_RAISE(h, e) ((h)->raise((h), (e)))
void exception_raise(struct exception_handler *e,
const struct exception *h);
#if DEBUG_TRACE
# define EXCEPTION_RAISE exception_raise
#else /* !DEBUG_TRACE */
# define EXCEPTION_RAISE(h, e) ((h)->raise((h), (e)))
#endif /* !DEBUG_TRACE */
#define STATIC_EXCEPTION_HANDLER(r, p) \
{ STATIC_HEADER, (r), (p) }
{ STATIC_HEADER, (r), (p), __FILE__ ":" STRING_LINE ": Static" }
#define HANDLER_CONTEXT (__FILE__ ":" STRING_LINE ": " FUNCTION_NAME)
/* Exception types. */
......@@ -75,12 +88,6 @@
#define EXC_IO_OPEN_WRITE 0x2006
#define EXC_IO_LISTEN 0x2007
#if 0
/* Not really errors */
/* EOF was read */
#define EXC_IO_EOF 0x2010
#endif
/* Authorization errors */
#define EXC_AUTH 0x4000
#define EXC_USERAUTH 0x4001
......@@ -133,15 +140,8 @@ extern struct exception dummy_exception;
struct exception_handler *
make_report_exception_handler(UINT32 mask, UINT32 value,
const char *prefix,
struct exception_handler *parent);
/* ;;GABA:
(class
(name exception_frame)
(super exception_handler)
(vars
(parent object exception_handler)))
*/
struct exception_handler *parent,
const char *context);
struct exception *
make_simple_exception(UINT32 type, const char *msg);
......@@ -150,7 +150,8 @@ make_simple_exception(UINT32 type, const char *msg);
struct exception_handler *
make_exception_handler(void (*raise)(struct exception_handler *s,
const struct exception *x),
struct exception_handler *parent);
struct exception_handler *parent,
const char *context);
/* A protocol exception, that normally terminates the connection */
/* GABA:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment