diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-09-26 11:46:38 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-09-26 11:46:38 -0700 |
commit | 33a68acb14759cb6fcf796b41ad001c93de4b8e4 (patch) | |
tree | f03543b04c0e5b7ce7f2650ff1330919d4d6e055 /src/upb.c | |
parent | 4b47002198f2c0404e16d2f02786845d6d3a0d3b (diff) |
Use a status object for errors so a message can be returned.
Also delay deletion of subfields until the entire message is
deleted.
Diffstat (limited to 'src/upb.c')
-rw-r--r-- | src/upb.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -5,6 +5,7 @@ * */ +#include <stdarg.h> #include <stddef.h> #include "upb.h" @@ -35,3 +36,14 @@ struct upb_type_info upb_type_info[] = { TYPE_INFO(BYTES, UPB_WIRE_TYPE_DELIMITED, struct upb_string*) }; +void upb_seterr(struct upb_status *status, enum upb_status_code code, + const char *msg, ...) +{ + if(upb_ok(status)) { // The first error is the most interesting. + status->code = code; + va_list args; + va_start(args, msg); + vsnprintf(status->msg, UPB_ERRORMSG_MAXLEN, msg, args); + va_end(args); + } +} |