<p>It depends on the type of errors that are being thrown.  If they are Twig/template errors, then you can can set the <a href="https://craftcms.com/docs/config-settings#suppressTemplateErrors" rel="nofollow">suppressTemplateErrors</a> config setting to <code>true</code> and they will simply get logged and the page request will continue as usual.</p>

<p>If they are non-Twig exceptions, then you'd have to do something more fancy like make a plugin that's essentially a facade for the Imager plugin and wraps all of it's calls in a <code>try/catch</code> block that just swallows any exceptions.</p>

<p>Or make a pull request that added support for it to the plugin itself.</p>

CC BY-SA 3.0
2016-03-31T15:46:48.820Z
Good idea about creating a wrapper. I'll try that, thanks @Brad Bell
Yuri Salimovskiy
CC BY-SA 3.0
2016-04-01T14:22:32.397Z
Ended up modifying Imager and submitting pull request
Yuri Salimovskiy
CC BY-SA 3.0
2016-03-28T19:53:25.860Z
2016-03-28T19:53:25.860Z
Brad Bell
<p>On certain pages of my site, I download and display resized (using the <a href="https://straightupcraft.com/craft-plugins/imager" rel="nofollow">Imager</a> plugin) images from remote site.</p>

<p>Now, sometimes that remote site returns error and in such case Imager is throwing exceptions, blocking the whole page from being viewed.</p>

<p>Now, is there a way to suppress server errors when possible, e.g. write them to log file and don't stop page processing?</p>

<p><a href="https://straightupcraft.com/craft-plugins/imager" rel="nofollow">devMode</a> is set to <code>false</code>.</p>

CC BY-SA 3.0
2016-03-28T16:33:23.790Z
What errors are you getting?
RitterKnight
CC BY-SA 3.0
2016-03-31T15:46:05.427Z
Telling image can't be resized (related to the fact that the remote server does not return 404 code but merely showing 'not found' page)
Yuri Salimovskiy
<plugins><error-handling><plugin-imager>
How to suppress server errors in Craft?
# How to suppress server errors in Craft?

(Asked by: username_0 on 2016-03-28)

On certain pages of my site, I download and display resized (using the [Imager](https://straightupcraft.com/craft-plugins/imager) plugin) images from remote site.

Now, sometimes that remote site returns error and in such case Imager is throwing exceptions, blocking the whole page from being viewed.

Now, is there a way to suppress server errors when possible, e.g. write them to log file and don't stop page processing?

[devMode](https://straightupcraft.com/craft-plugins/imager) is set to `false`.

**Tags:** plugins, error-handling, plugin-imager
> **Comments:**
> **username_1**: What errors are you getting?  
> **username_0**: Telling image can't be resized (related to the fact that the remote server does not return 404 code but merely showing 'not found' page)  

---

## 1 answers

### Answer by username_2 on 2016-03-28. Score: 2 | Accepted answer

It depends on the type of errors that are being thrown. If they are Twig/template errors, then you can can set the [suppressTemplateErrors](https://craftcms.com/docs/config-settings#suppressTemplateErrors) config setting to `true` and they will simply get logged and the page request will continue as usual.

If they are non-Twig exceptions, then you'd have to do something more fancy like make a plugin that's essentially a facade for the Imager plugin and wraps all of it's calls in a `try/catch` block that just swallows any exceptions.

Or make a pull request that added support for it to the plugin itself.

> **Comments:**
> **username_0**: Good idea about creating a wrapper. I'll try that, thanks @Brad Bell  
> **username_0**: Ended up modifying Imager and submitting pull request  

---

