
On 9/27/12 12:43 PM, Chaddaï Fouché wrote:
On Thu, Sep 27, 2012 at 9:25 PM, Chaddaï Fouché
wrote: body <- try (simpleHttp "http://www.google.com") case body of Left (SomeException _) -> jsonToRepJson $ object ["response" .= ( show "ERROR: NO DATA FOR ONE REASON OR ANOTHER")]
I think that should work...
Thank you for that Jedai! That looks MUCH MUCH cleaner than the :: GHandler ... type signature.
Since the signature was made necessary by the ambiguity on which type of exception you wished to catch with your "try", using (SomeException _) in your pattern match should make that clear. By the way, why are you show()ing a String ? The only thing that does is adding quotes around it and escaping some characters, shouldn't you just use :
Left (SomeException _) -> jsonToRepJson $ object ["response" .= "ERROR: NO DATA FOR ONE REASON OR ANOTHER"]
I was doing that because when I removed it, I got an error similar to this: Ambiguous type variable `a0' in the constraints: (Data.String.IsString a0) arising from the literal `"ERROR: "' at playhaven.hs:54:73-81 (aeson-0.6.0.2:Data.Aeson.Types.Class.ToJSON a0)
which I was able to remove by throwing a show in there. If you know of a better way I would love to know about it. Thanks again! Bryce