Fix warning: ‘error’ may be used uninitialized in this function