#> Error in eval(expr, envir, enclos): Funds exhausted
出现问题可能有各种原因:数据出错、用户错误、网络故障以及代码中的错误等。原因
可能有很多。适当提前考虑到潜在的问题和代码是很重要的:
检测
至少检测可能的错误。如果无法进一步处理,则停止。未检测到的错误是程序失败
的主要原因。
报告
如果必须停止,请向用户提供合理的解释原因。这将有助于他们诊断和解决问题。
恢复
在某些情况下,代码可能能够自行纠正该情况并继续。但是,我们建议警告用户,
其代码遇到问题并需要纠正。
错误处理是
防御性编程
的一部分,是使代码稳健的做法。
15.7.4 另请参阅
使用stop函数的替代方法是使用warning函数,它可以输出消息并继续程序而不会
停止。但是,请确保继续处理是合理的。
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.