You're right, that message will never be displayed after the 500 error.  So
I'll just remove those echo statements in the catch block.


On Tue, Aug 27, 2013 at 3:09 PM, Emmerich, Christopher
<emmerichc@usgs.gov>wrote:

> What do you think the approach should be?  I could do something like this:
>
> <?php
>
> // load config after ensuring required parameter is present
> include_once '../conf/config.inc.php';
>
>
> // process request
>
> try {
> // 09/04/12 -- EMM: This exception is for testing client-side error
> handling.
>  //                  Remove it for production.
>        // throw new Exception('foo');
>         $json = json_encode($OBSERVATORY_FACTORY->getObservatories());
> } catch (Exception $e) {
> // fail noisily
> header('HTTP/1.1 500 Internal Server Error');
>  //echo '{"error": "'.$e->getMessage().'"}';//"Unable to process
> request"}';
> echo '{"error": "Unable to process request"}';
>  echo $e;
> // log the error
> error_log($e->getMessage());
>
> exit();
> }
>
> header('Content-Type: application/json');
> echo $json
>
>
> On Tue, Aug 27, 2013 at 1:02 PM, Jeremy Fee <notifications@github.com>wrote:
>
>> In src/htdocs/observatory_summary_feed.php:
>>
>> > +// process request
>> > +header('Content-Type: application/json');
>> > +
>> > +try {
>> > +	// 09/04/12 -- EMM: This exception is for testing client-side error handling.
>> > +	//                  Remove it for production.
>> > +    // throw new Exception('foo');
>> > +
>> > +	echo json_encode($OBSERVATORY_FACTORY->getObservatories());
>> > +
>> > +} catch (Exception $e) {
>> > +	// fail noisily
>> > +	header('HTTP/1.1 500 Internal Server Error');
>> > +	//echo '{"error": "'.$e->getMessage().'"}';//"Unable to process request"}';
>> > +	echo '{"error": "Unable to process request"}';
>> > +	echo $e;
>>
>> The message should probably not be output after the json.
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/usgs/geomag-baseline-calculator/pull/28/files#r6014773>
>> .
>>
>
>