Any way to handle readDir errors?

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

Currently no, but there are obvious improvements here.