O'Reilly logo

Applied Microsoft® .NET Framework Programming by Jeffrey Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What Exactly Is an Exception?

Over the years, I’ve run into many developers who think that an exception identifies something that rarely happens: "an exceptional event." I always ask them to define "exceptional event." They respond, "You know, something you don’t expect to happen." Then they add, "If you’re reading bytes from a file, eventually you’ll reach the end of the file. So because you expect this, an exception shouldn’t be raised when you reach the end of the file. Instead, the Read method should return some special value when the end of the file is reached."

Here’s my response: "I have an application that needs to read a 20-byte data structure from a file. However, for some reason, the file contains only 10 bytes. In this case, I’m not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required