.NET exception throwing guidelines

01/24/09

.NET exception throwing guidelines

I put together a flowchart based on the exception throwing guidelines in Framework Design Guidelines 2nd Ed. It’s available in PDF format at:

ExceptionsDotNet.zip (1.75 MB)

Note: These are just guidelines. InvalidOperationException is not the only choice at one point in the flowchart; to quote the book, “The list is by no means exhaustive.” For developers who return error codes, return null on failure, throw System.Exception, etc., following these guidelines will keep them out of trouble. (Hopefully that’s not my readership, but I’m sure you know a coworker…)

Update - January 27, 2009

Readers might find this blog article interesting as well:

Finding the right exception to throw


Your Host: webmaster@truewill.net
Copyright © 2000-2013 by William Sorensen. All rights reserved.