Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've created a gateway which receives a POST from cUrl on one system which is a well-formed XML string. After processing the gateway sends back a response XML. All the fields in the XML are required and while the system sending the data constructs the XML itself I'm running some validation to make sure that every value that's being stored in the Request Class is actually.

One thing my gateway does is that the response can also indicate an error and sends a message and response code which is then displaced on the system as the following message:

An unknown error occurred while processing. Code: # Message: ERROR_MESSAGE

The original code just sends Code as 0 if there was no error or 1 if there was. I'm thinking of giving Code another value depending on the error since displaying Code in the error message is kinda useless if it's only ever going to be 1 (since you'll never see 0). So I'm wondering if there is a standard for creating error codes, particularly with PHP and XML.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

I am not aware of any specific standard that could help you.

However, there are standard protocols to pass data on the web.

  1. SOAP has a concept of soap fault

    The SOAP Fault Element

    The optional SOAP Fault element is used to indicate error messages.

  2. REST generally uses HTTP error codes. Here is an example list to show you how it could be done.

I would strongly advise you to adopt an open standards for your gateway and conform to known patterns. After all, gateways are meant to be shared resources...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.