move logger order so logging is done before error throwing