Log the error instead of simply printing it.