NYCPHP Meetup

NYPHP.org

[nycphp-talk] xmlhttp: conventions/practices for throwing error?

David Mintz dmintz at davidmintz.org
Fri Mar 10 12:40:00 EST 2006


On Fri, 10 Mar 2006, David Mintz wrote:

> I'm writing some PHP that expects some GET data, uses it to build SQL
> query, XMLifies the data from the result and echos it. The client is
> Javascript that submits an xmlhttp request. Suppose some of the GET input
> doesn't validate. Is there a convention/best practice for throwing an
> error to signal the client something is wrong -- e.g., do you send an HTTP
> error code in a header or some such? Or just echo something like
> <error>error message here</error>?

To partly answer my own question, after further reflection: no, I would
think HTTP error codes are for protocol-level issues rather than
application/data validation. I guess the client should check the
response by looking for, e.g., an <error> element. ?

---
David Mintz
http://davidmintz.org/

Amendment IV

The right of the people to be secure in their
persons, houses, papers, and effects, against
unreasonable searches and seizures, shall not be
violated, and no Warrants shall issue, but upon
probable cause, supported by Oath or affirmation,
and particularly describing the place to be
searched, and the persons or things to be seized.



More information about the talk mailing list