All Questions
Tagged with exceptions programming-practices
30 questions
0
votes
2
answers
210
views
Should I track my handled exceptions?
Various analytics tools will track the number of handled and unhandled exceptions (crashes) that happen in an app. This obviously helps us find problems we didn't know existed and will fix it.
Quite ...
40
votes
6
answers
38k
views
Try/Catch/Log/Rethrow - Is Anti Pattern?
I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I ...
4
votes
2
answers
263
views
Design of multi-test function to validate a string
Assume that I wish to perform an action on a string (e.g., print the string) if, and only if, the string first passes several tests. The tests are diverse (and may even be complex functions themselves)...
37
votes
4
answers
22k
views
Are exceptions for flow control best practice in Python?
I'm reading "Learning Python" and have come across the following:
User-defined exceptions can also signal nonerror conditions. For
instance, a search routine can be coded to raise an exception ...
1
vote
2
answers
2k
views
Throwing exceptions in application configuration providers
Simple question: What is the best/common practice regarding to throwing errors for application configuration providers?
Given is a simple key/value-based configuration source:
class Configuration
...
2
votes
7
answers
6k
views
Throwing an exception when a method does not complete or implement a work around? [duplicate]
I have been studying this subject quite a bit, and I am unsure of what's the best way. I still have a lot to go trough (books, blogs, stack exchange, etc), but I simply can't find a consensus.
...
34
votes
8
answers
15k
views
Is throwing an exception an anti-pattern here?
I just had a discussion over a design choice after a code review. I wonder what your opinions are.
There's this Preferences class, which is a bucket for key-value pairs. Null values are legal (that'...
6
votes
5
answers
6k
views
How to handle exceptions that get absorbed by a 3rd party library?
I'm currently having an issue with a 3rd party control library provider. They have an exception occulting culture that gets in the way of my general fail-fast approach when developing software.
An ...
2
votes
3
answers
556
views
Coerce bad input or always crash early
The general consensus seems to favor the Crash Early approach, the most reputable source being the acclaimed Pragmatic Programmer book.
And while I understand and agree with the advice in many ...
2
votes
1
answer
113
views
Under which circumstances does it make sense to lose track of where an exception was thrown from?
Is there any valid reason why a catch block on a lower layer would throw back an exception caused by a higher, unknown layer using the following syntax:
throw ex;
... rather than:
throw;
... ?
In ...
0
votes
2
answers
455
views
Advice needed on rethrowing an exception
Consider the following c# code:
public class ExceptionManager
{
public static void TreatException(Exception ex)
{
if (ShowAndContinue(ex))
// display a user-friendly ...
29
votes
7
answers
1k
views
Is it okay to use exceptions as tools to "catch" errors early?
I use exceptions to catch problems early. For example:
public int getAverageAge(Person p1, Person p2){
if(p1 == null || p2 == null)
throw new IllegalArgumentException("One or more of ...