TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

You should let it crash

9 点作者 whoputitthere超过 12 年前

1 comment

stkni超过 12 年前
I agree in principle, but the reality is different and so the principle can be hard to follow.<p>In languages without checked exceptions (like C#) you may end up in situation where you're collating and processing a large collection of items from a remote source. You've received bad data so ideally you'd just like to log that and not make the application go down.<p>But the exception may get thrown by any one of thousands of methods in your own application or a library. So checking the source to see what's thrown and adding specific handlers might not be possible or achievable. Checking the documentation might be an option but in general it's too time consuming or just non-existant.<p>So to cope I catch a generic Exception, log the bad data, and carry on.<p>So yet again what we have is a principle we should aim for but depending on circumstance you can feel free to ignore.