|
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.
|
|
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....
|
|
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 .
|
Ask your Facebook Friends
|
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).
|
|
In c++, Iam trying to catch all types of exceptions in one catch (like catch(Exception) in C#). how is it done ? and more, how can one catch devide-by-zero exceptions ?
Started by gil on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Catch(...) will also catch certain serious system level exceptions (varies depending into exceptions that you can gladly....
}
Important considerations:
A better approach exceptions.
Catch (...) { // Handle exceptions not covered.
|
|
Some friends just finished the implementation of an app and they use Custom Exceptions. something that took my attention is that when a custom exception was raised they logged the exception in the code of the exception base class they implemented. so ...
Started by Oscar Cabrero on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Bottom line, it's not common, but it is possible that Exceptions are not thrown when writing caught exceptions....
Since Exceptions constructed).
exception that is created is going to be thrown, which is definitely not the case.
|
|
In java the compiler complains about uncatched exceptions.
I use exceptions in C++ and I miss that feature.
Is there a tool out there capable of doing it? maybe a compiler option (but I doubt it)
Started by f4 on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Typically this will be enough:
try { //do stuff } catch piece of code - throwing exceptions....
Of course, you really don't want to catch most exceptions at this level, but you can at least to catch all exceptions at the top level.
Levels.
|