资 源 简 介
Error handling is not too trivial to share.
Just a few archetypes characterize many of the .NET applications in existence. For example, failing web applications should usually respond with a 4XX or 5XX response. We usually expect crashing console applications to return non-zero exit status and write a message to standard error. The code that captures this common behavior ought to be reused, even if it is simple.
Although it seems simple, last-resort error handling is often an afterthought and occasionally implemented so badly that it can actually make things worse (e.g., crashing the ASP.NET host process when a NullReferenceException is encountered in user code dealing with a single request).