David,
The approach I tend to use is to catch the exception in the Handler and
set the Status of the Response there to SERVER_ERROR_INTERNAL.
HTH,
AJ
Quoting David Choi <[EMAIL PROTECTED]>:
> David Choi <daft.davy <at> gmail.com> writes:
>
> >
> > Hello,
> >
> > When constructing DOM documents to create DOM Representations (or,
> for that
> > matter, JSON Objects for JSONRepresentations), I need to return a 500
> Internal
> > Server Error when DOM Document/JSON Object creation throws an
> exception.
> >
> > For example:
> > JSONObject jObj = new JSONObject();
> > try
> > {
> > jObj.put("blah", blah);
> > ...
> > }
> > catch(JSONException e)
> > {
> > //something needed here?
> > }
> >
> > What is the best way to do this? Currently, if the exception occurs,
> I just
> > skip adding the representation to the list of variants returned by
> > getVariants(), but this returns a 404 - Resource Not Found.
> >
> > Thanks,
> > David
> >
> >
>
> I should clarify:
> This is being done on the Resource level. From my
> "List<Representation>
> getVariants()" method, I call the above methods to create JSON/DOM, and
> it is
> here that I need to set the response status to error 500.
>
> Thanks,
> David
>
>
--
A.J. Barnes, B.Sc., B.N.
Poisons Information Officer
National Poisons Centre / Te Kaunuku Paitini O Aotearoa
Ph: +64 3 479 7250
Fax: +64 3 477 0509
=======================================================
CAUTION: This e-mail message may contain information that is
confidential
and subject to privilege. It is intended solely for the addressee. If
you
are not the intended recipient, you are notified that any use,
distribution
or copying of this message or data is prohibited. If you received this
e-mail in error, please notify me immediately and delete all material
pertaining to this e-mail. Thank you.