1
vote
1answer
168 views

Separate namespace just for exceptions?

I was doing a code review and came across something odd which I've never seen before. The developer decided to create a sub-namespace just to contain all the assembly's exceptions. I thought I had ...
3
votes
2answers
155 views

Is it an acceptable practice to Get a property, that involve parsing binary, that might throw an exception?

I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. ...
1
vote
1answer
173 views

Either Monad and Exceptional Circumstances [duplicate]

I have a function returning an Either such as GetUserFromDb(int id). If the database is offline, should I catch the error in the function and wrap it in a failure / Left case or should I let it ...
5
votes
4answers
587 views

What's the reason exceptions are heavily used in managed (C# and Java) languages but not in C++? [closed]

AFAIK, a lot of C++ projects don't allow exceptions and deny them in coding guidelines. I have a lot of reasons, for example, exception is hard to handle correctly if your binary needs to be compiled ...
1
vote
1answer
230 views

Does this violate the using exceptions for flow control “rule”?

I plan to make use of this interface in a plug-in architecture. /// <summary> /// Generic interface allowing you to react to an event. /// You can block the event or just use it for ...
5
votes
8answers
764 views

Best Practice for Argument Checking

Say I have a web service with a method MyWebServiceMethod(string passedValue). The web service calls a method MyServiceMethod(string passedValue) where the value from the web service is passed along. ...
6
votes
4answers
594 views

“Programming error” exceptions - Is my approach sound?

I am currently trying to improve my use of exceptions, and found the important distinction between exceptions that signify programming errors (e.g. someone passed null as argument, or called a method ...
25
votes
9answers
6k views

Is catching general exceptions really a bad thing?

I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one: CA1031: Do not catch general exception types I understand the ...
4
votes
2answers
413 views

I have a stacktrace and limit of 250 characters for a bug report

I'm developing an xbox indie game and as a last-resort I have a try...catch encompassing everything. At this point if an exception is raised I can get the user to send me a message through the xbox ...
9
votes
4answers
4k views

How to simulate events that cause exceptions to test try/catch blocks?

I understand how exceptions work and how to catch and handle them in C# but how can I simulate events that may cause an exception to ensure that it is caught correctly? For example, is it possible to ...
19
votes
12answers
2k views

How to teach Exception Handling for New Programmers?

How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily. With ...