How to display errors when querying a dynamic XML document?

I am currently writing a PHP script that third party clients will be able to access with using GET. This will require several GET parameters and return an XML document with the results.

My question is, if the required GET parameters are not honored or contain invalid data, how do I display errors to the end user?

Should I return a completely different XML document with error data, or the same XML document with errors in existing fields, or just put errors in HTML?

+2


a source to share


1 answer


How is content requested? Are some users viewing the page? Or another PHP script asking for these details? If the PHP script is requesting XML, I would just output HTTP 400 Bad Request. If this is a person browsing the site, I think a friendly error page would be fine if the options are critical.

For example, if they ask



xml.php? File = report1584.xml

but they did not provide a file parameter, you would just tell them an error occurred and no file was specified.

+2


a source







All Articles