catch ValueError and IOError.