Handle connection errors with a decorator