Hi Phil,
I was wondering if there is a way to handle erors gracefully in REST. For instance, I am using REST to parse xml returned from an outside database based on a parameter sent in the request. I use a segment variable to set the request pararmeter in my template, so my REST tag looks like this:
{exp:rest url="http://media.lpb.org/pbcore/api/GetAssetDetails.ashx" verb="get" format="xml" param:asset_identifier="{segment_3}"}
Now generally users will be accessing this template by clicking a link that will have the necessary asset id populated in segment 3 as part of the link, but there is always the possibility that someone could type a random parameter into the segment 3 position, so I was wondering if there is a way to handle that gracefully. Right now as it stands, when I put in a value in the segment position that is obviously going to cause an error, I get a blank screen (the template doesn’t render). The xml that is returned for the request is as follows:
<Error> <ErrorMessage>Asset Not Found</ErrorMessage> </Error>
I recognize this could just be a matter of my not using the tag properly, but any suggestions you have would be welcome. I’d like to be able to either do a 404 redirect or at least display an error message in the template.
Thanks,
Brian
|