# Any way to handle readDir errors?

**URL:** <https://discourse.gohugo.io/t/any-way-to-handle-readdir-errors/3465>\
**Category:** support\
**Created:** [June 6, 2016, 4:27am UTC](https://discourse.gohugo.io/t/any-way-to-handle-readdir-errors/3465 "2016-06-06T04:27:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saimiri](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/saimiri/32/1678_2.png) [@saimiri](https://discourse.gohugo.io/u/saimiri)\
**Post date:** [June 6, 2016, 4:27am UTC](https://discourse.gohugo.io/t/any-way-to-handle-readdir-errors/3465/1 "2016-06-06T04:27:10Z")

</div>

I noticed that if I point `readDir` at a non-existing directory, Hugo spits out an error and stops rendering the partial template where the error occurred. I have circumvented this by putting the `readDir` and the following `range` loop in their own partial, so the HTML stays intact even if that partial is rendered… well, only partially.

Is there any way to handle this more gracefully? It would be nice to either

- be able to check beforehand if a directory exists, or
- to receive a meaningful value from readDir in case of an error

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 6, 2016, 8:32am UTC](https://discourse.gohugo.io/t/any-way-to-handle-readdir-errors/3465/2 "2016-06-06T08:32:13Z")

</div>

Currently no, but there are obvious improvements here.
