Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [dsdp-tcf-dev] how to add custom errors in TCF agent?

Hi Ed,
 
errors API might be a bit confusing because it is designed to support POSIX style of error reporting using errno variable.
 
To create an error report you do something like this:
 
    int no = 0;
    ErrorReport * err = create_error_report();
    ... set report fields...
    no = set_error_report_errno(err);
    release_error_report(err);
 
Now "no" contains an error code that points to error report you have created. You can use the code as a value for errno variable. Note that such error codes are assigned dynamically and are recycled later, but the code remains valid at least until current dispatch cycle ends.
 
To send the report over JSON:
 
    write_errno(out, no);
 
Regards,
Eugene.


From: dsdp-tcf-dev-bounces@xxxxxxxxxxx [mailto:dsdp-tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of Ed.Swartz@xxxxxxxxx
Sent: Tuesday, June 01, 2010 1:22 PM
To: dsdp-tcf-dev@xxxxxxxxxxx
Subject: [dsdp-tcf-dev] how to add custom errors in TCF agent?

 
Hi,
 
In the reference TCF agent code, I'm having trouble figuring out how to add a custom error reply, which isn't errno or a system error, without hand-coding a lot of json calls.
 
I.e. I'd like for a service to reply to a command with an error that has all the standard fields (timestamp, error code, format, provider, etc) but with a custom message.
 
It looks like errors.c potentially supports a range of custom error messages and some way to add content to it with ErrorReport/ErrorMessage structs.  But I wonder if I'm fooling myself, because ERR_MESSAGE_MIN/MAX and SRC_SYSTEM/GAI/MESSAGE/REPORT enums are only available inside errors.c, not in the header.
 
If I use "create_error_report()", which seems to be the API for this, how do I write the error object over json?  I.e. how can I combine what get_error_report() does with this?
 
-- Ed
 
 
 

Back to the top