|
I've been updating an existing library to throw exceptions to help improve debugging by people using the library.
At first, I thought I'd define exceptions specific to each class, however it turns out most of those exceptions are simply extensions of ...
Started by Carl on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
This is not to say that you should never use custom exceptions....
Use the standard exceptions.
Extending the Exceptions without adding any value like this is a complete waste of time and incurs an ongoing maintenance cost that is best avoided.
|
|
I am wondering how in practice other SOers tend to deal with and/or prevent exceptions.
In what situations do you prevent exceptions, and how? In what situations do you catch exceptions?
I usually prevent 'NullPointerExceptions' (and other similar ones...
Started by Tnay on
, 13 posts
by 13 people.
Answer Snippets (Read the full thread at stackoverflow):
For example, any it's a RuntimeException.)
Exceptions are more useful when you expect to be able to detect a failure condition in one -- or all of the way up ....
If you can prevent exceptions, then it's better programming practice to do so.
|
|
Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux?
This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called).
Started by Geoffrey Irving on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Due to the way signals and exceptions work, you can't do it immediately when the signal is thrown - exceptions rely on certain aspects of the stack that aren't true when a signal handler gets called (not sure whether you can safely throw....
|
Ask your Facebook Friends
|
Is there a way to annotate a method so all exceptions thrown are converted to runtime exception automagically?
@MagicAnnotation // no throws clause! void foo() { throw new Exception("bar")' }
Started by ripper234 on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
--
Edit: Personally I believe....
May I ask why you want to suppress the checked exceptions?
1 according a method wrapper which calls the desired method with exceptions and all inside a
try" in an annotation .
Only unchecked exceptions 2 .
|
|
I have read that there is some overhead to using C++ exceptions for exception handling as opposed to, say, checking return values. I'm only talking about overhead that is incurred when no exception is thrown. I'm also assuming that you would need to implement...
Answer Snippets (Read the full thread at stackoverflow):
The overhead should generally be negligible in every....
Only try/catch and try/except block take a few instructions to set up.
The overhead mainly comes from using exceptions as control logic, when an exception with.
It's the same.
|
|
I have some code that gives a user id to a utility that then send email to that user.
emailUtil.sendEmail(userId, "foo"); public void sendEmail(String userId, String message) throws MailException { /* ... logic that could throw a MailException */ }
MailException...
Started by SCdF on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
You might want to throw individual exceptions of the exceptions encapsulated in the mailException but not others In most cases I would say just log the text of the exception and don't ....
It depends on what your application is doing.
|
|
I want the api of my module to only throw MyPackageSpecificException whenever anything goes wrong and the module unable to perform its task. (The original exception will be given as the cause of the MyPackageSpecificException).
Now, for one constructor...
Started by Alderath on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
} public static MyClass createMyClass(String urlString) throws MyPackageSpecificException { try { new MyClass(urlString); catch (Exception....
If it fits your code, you can use a static creator method instead:
private MyClass(String urlString) { .. .
|
|
I am creating some custom exceptions in my application.
If I have an exception that gets thrown after testing the state of an argument, Or I have an Exception that gets thrown after testing that an int is within the proper range, should my exceptions ...
Started by Sruly on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
I'm just curious, why wouldn't you actually use the Exceptions that are already there? It sounds like these exceptions are exactly what you need, why are you against using those?
Personally similar but not exactly the same exceptions....
|
|
Where are exceptions stored ? Stack, Heap. How is memory allocated and deallocated for Exceptions? Now if you have more than one exception which needs to be handled are there objects of all these exceptions created?
Started by Thunderboltz on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
They can be nested garbage-collected like everything else.
There cannot be two exceptions being thrown at the same time (on the same thread).
I would assume that memory for exceptions is allocated the same way as for all other objects).
|
How and where to handle exceptions in a 3-tier web application? Specifically Sql Database Exceptions
I'm building the standard 3-tier ASP.NET web application but I'm struggling as to where to do certain things - specifically handling exceptions.
I've tried to have a look around on the web for some examples but can't find any which go as far as a whole...
Started by Nick on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Handling exceptions lower down in the call such as the SqlConnection), document ....
-Krip
I believe its best practice to handle exceptions at the last responsible, and what needs to be done if something doesn't work.
Or business tiers.
|