catch exception while saving files