olivierbon / Placid

Placid is a Craft plugin which makes it easy to consume REST services in your twig templates
77 stars 5 forks source link

Make Placid a bit more fault-tolerant #3

Closed mildlygeeky closed 9 years ago

mildlygeeky commented 9 years ago

Really enjoying the ease of use on this, but I'm a bit afraid of what will happen if the news feed I'm ever consuming with it goes down.

From what I've found so far if Placid encounters an API that is throwing a 404, for example, it throws an error that keeps the frontend of the website from rendering (but please tell me if there is a way to more gracefully handle this).

Would love to see some sort of .request object that could be checked for a true / false value, as then I could fail more gracefully and pop up a little error message of "Our news feed could not be loaded at this time" if an API was unavailable.

alecritson commented 9 years ago

Hey thanks for using Placid.

I completely understand where you are coming from, I've just released an update which should handle these situations more gracefully and not stop the template from rendering.

Now if a request fails Placid will return as null and an error will be logged in the Craft log with the message of what went wrong. So now in your templates you could check against this and display your message for when things aren't going to be displayed

I hope that helps! :)