sbrcsr 3.2.0
ATOMAS sbrcsr
Error handling

Overview

SBRCSR errors originate from 3 broad sources:

The first two are returned to the client code as errcodes and ato_Error objects. The last is not viewed as an API error but a business processing error and should be handling as per the SBR WIG (Web services Implementation Guide).

When submitting documents to SBR, first check if an errcode has been returned, and if so process the error as per normal error handling further below.

Business Document Errors

If no API error has occurred, the returned response should be checked for business level errors. This involves checking the Response eventitems elements for information. In particular, sbr_res_ismaxseveritycode("Error") and sbr_res_ismaxseveritycode("Warning") should be used to check for problems.

Following is a code snippet reflecting the approach outlined in the WIG. See the WIG and sample code for further details.

static void _process_eventitems(sbr_Response *response)
{
size_t indent = 1;
sbr_Sbdm *sbdm = NULL;
size_t i = 1, icount = 0;
icount = sbr_res_sbdm_count(response);
for (sbdm = sbr_res_sbdm_firstv(response); sbdm; sbdm = sbr_res_sbdm_nextv(response), i++) {
sbr_MsgEventItem *ei = NULL;
size_t j = 1, jcount = sbr_sbdm_eventitem_count(sbdm);
printf("SBDM %d of %d\n", i, icount);
for (ei = sbr_sbdm_eventitem_firstv(sbdm); ei; ei = sbr_sbdm_eventitem_nextv(sbdm), j++) {
dump_eventitem(stdout, &indent, ei, j, jcount, FALSE);
}
}
}
static void _process_csrresponse(ato_Ctx *ctx, sbr_Response *response)
{
if (sbr_res_ismaxseveritycode(response, "Error")) {
printf("maxseveritycode of %s found\n", "Error");
_process_eventitems(response);
} else {
if (sbr_res_ismaxseveritycode(response, "Warning")) {
printf("maxseveritycode of %s found\n", "Warning");
} else if (sbr_res_ismaxseveritycode(response, "Information")) {
printf("maxseveritycode of %s found\n", "Information");
} else {
printf("maxseveritycode of %s found\n", "?unknown?");
}
_process_eventitems(response);
dump_response(ctx, response, "sbrcsr_response_dump.txt");
}
}
struct _ato_Ctx ato_Ctx
struct _sbr_MsgEventItem sbr_MsgEventItem
This contains information from the service about the request and transaction that occurred.
Definition: msgevent.h:16
SBR_CSR_EXPORT sbr_Sbdm * sbr_res_sbdm_nextv(sbr_Response *response)
Get the next sbdm of the collection.
SBR_CSR_EXPORT bool sbr_res_ismaxseveritycode(sbr_Response *response, const char *severitycode)
Search the maxseveritycode for all sbdms for the given value (response only).
SBR_CSR_EXPORT size_t sbr_res_sbdm_count(sbr_Response *response)
Return the number of sbr_Sbdm objects in the response.
SBR_CSR_EXPORT sbr_Sbdm * sbr_res_sbdm_firstv(sbr_Response *response)
Get the first sbdm of the collection.
struct _sbr_Response sbr_Response
The CSR response object for a given sbr_CsrRequest.
Definition: response.h:12
struct _sbr_Sbdm sbr_Sbdm
The CSR SBDM object.
Definition: sbdm.h:18
SBR_CSR_EXPORT sbr_MsgEventItem * sbr_sbdm_eventitem_nextv(sbr_Sbdm *sbdm)
Get the next event item of the collection (response only).
SBR_CSR_EXPORT size_t sbr_sbdm_eventitem_count(sbr_Sbdm *sbdm)
Get the number of event items (response only).
SBR_CSR_EXPORT sbr_MsgEventItem * sbr_sbdm_eventitem_firstv(sbr_Sbdm *sbdm)
Get the first event item of the collection (response only).

Handling API Errors

SBRCSR uses the error handling mechanism in ATOBASE.

For iterating errors see Iterating the error "stack".

SBRCSR API methods which return errcodes will always return an SBR_CSR_ERR_.. code. For details on errcodes see Error codes.

Top level errcodes can be checked using:

switch (errcode) {
printf("CSR General error: ");
break;
printf("CSR Sender error: ");
break;
printf("CSR Receiver error: ");
break;
printf("CSR Remote Service not available: ");
break;
printf("CSR Network error: ");
break;
printf("CSR Remote Service timeout: ");
break;
}
#define SBR_CSR_ERR_NETCOMMS
A general network error has occurred, not including timeouts.
Definition: types.h:95
#define SBR_CSR_ERR_NETSENDER
A SOAP fault generated by the sender, not including service unavailable.
Definition: types.h:92
#define SBR_CSR_ERR_NETTIMEOUT
A network time has occured trying to connect to a remote service.
Definition: types.h:96
#define SBR_CSR_ERR_NETRECEIVER
A SOAP fault generated by the receiver, not including service unavailable.
Definition: types.h:93
#define SBR_CSR_ERR_NETUNAVAILABLE
A SOAP fault where the remote service is unavailable.
Definition: types.h:94
#define SBR_CSR_ERR_GENERAL
For errors not specified below.
Definition: types.h:91