ImageBundle icon indicating copy to clipboard operation
ImageBundle copied to clipboard

Bad error handling

Open webberig opened this issue 12 years ago • 2 comments

While using this bundle, I often get following error:

Error: Method Gregwar\ImageBundle\ImageHandler::__toString() must not throw an exception in D:\Projects\webberig\app\cache\dev\classes.php line 0

The cause is usually a simple problem. The image file doesn't exist, the cache folder doesn't exist, etc... The problem is that the actual error is nowhere to be found and the execution of the page is interrupted.

I suggest the following solution:

  • Catch the exception (ie. inside the Image::guess method) and provide a fallback value (an error page that returns a 404 error) or perhaps a base64 string with a grey image
  • Log the exception using the logger service

webberig avatar Sep 22 '13 08:09 webberig

Hi, and thanks for reporting

This issue was already discussed #9

However the idea of logging it in the logger was not proposed, and I like it

If we add fallback images, I think that it should be optional and display a clearly "error" string in the image

Gregwar avatar Sep 22 '13 10:09 Gregwar

+1 for this.

It's frustrating having no explanation of the error.

AdamBoxall avatar Jan 25 '15 14:01 AdamBoxall