Handle exception if db unavailable, refs #4851