Is there a way to get a list of all exceptions that can be thrown by a program....
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
Hope I'm not asking a dumb question but is the code you're executing within a try / catch block? Second question is do you what is causing the exception yet?
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
try this: try { ..... ..... } catch(Exception ex) { ...... ...... }
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
edaindia wrote:
a list of all possible exceptions
No. FYI: The list of things that can go wrong in Windows would be infinite. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Merry Christmas and a Happy New Year to all.
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
edaindia wrote:
Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown
Not that I know of. Well, that's a bit of a lie; you could loop through all the assemblies that are loaded, and list those classes that inherit from Exception. The programmers should already be handling the errors that they can expect locally with a try-catch block, as has been noted a few times. The exceptions that remain should be handled in the "global exception handler". There's an event called
ThreadException
[^] that gets raised whenever there's some exception that didn't get handled by the try-catch blocks. If you don't handle those, you'll get an ugly exception-screen. Now, you want a list of all the exceptions that can occur there? Well, everything that's derived fromException
- hence the suggestion to just log "everything" that triggers theThreadException
event. Good luck :)I are Troll :suss:
-
edaindia wrote:
a list of all possible exceptions
No. FYI: The list of things that can go wrong in Windows would be infinite. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Merry Christmas and a Happy New Year to all.
And more often than not, there's not a damn thing you can do about it.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
Just put a try/catch block around everything that could fail, and there you have it.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Hope I'm not asking a dumb question but is the code you're executing within a try / catch block? Second question is do you what is causing the exception yet?
JasonLee07 wrote:
Hope I'm not asking a dumb question but is the code you're executing within a try / catch block?
Some of the code is ... and some is not.... The current approach is I test various features of the application until it pop-ups an unhandled exception after which the offending piece of code is encapsulated in an try {...} catch {...} block What I was looking for is a formal method of getting a list of all possible code blocks which can throw an exception and performing a code review to ensure that all exceptions are properly handled.....
JasonLee07 wrote:
Second question is do you what is causing the exception yet?
I have root caused the exceptions which were triggered by my testcases.
-
edaindia wrote:
Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown
Not that I know of. Well, that's a bit of a lie; you could loop through all the assemblies that are loaded, and list those classes that inherit from Exception. The programmers should already be handling the errors that they can expect locally with a try-catch block, as has been noted a few times. The exceptions that remain should be handled in the "global exception handler". There's an event called
ThreadException
[^] that gets raised whenever there's some exception that didn't get handled by the try-catch blocks. If you don't handle those, you'll get an ugly exception-screen. Now, you want a list of all the exceptions that can occur there? Well, everything that's derived fromException
- hence the suggestion to just log "everything" that triggers theThreadException
event. Good luck :)I are Troll :suss:
Eddy Vluggen wrote:
Not that I know of. Well, that's a bit of a lie; you could loop through all the assemblies that are loaded, and list those classes that inherit from Exception.
Is there any way to do this?
Eddy Vluggen wrote:
The programmers should already be handling the errors that they can expect locally with a try-catch block,
My concern was about finding those sections of code which should be within a try catch block, but are not. If the exception was caught at the right location the programmer would have various options (e.g. abort,retry,ignore). Hence the emphasis on finding a formal way to identifying all code sections which can throw an exception and resolving them through a code review. A global exception handler would be my last resort at the time of actual deployment. Thanks for the reply....
-
Eddy Vluggen wrote:
Not that I know of. Well, that's a bit of a lie; you could loop through all the assemblies that are loaded, and list those classes that inherit from Exception.
Is there any way to do this?
Eddy Vluggen wrote:
The programmers should already be handling the errors that they can expect locally with a try-catch block,
My concern was about finding those sections of code which should be within a try catch block, but are not. If the exception was caught at the right location the programmer would have various options (e.g. abort,retry,ignore). Hence the emphasis on finding a formal way to identifying all code sections which can throw an exception and resolving them through a code review. A global exception handler would be my last resort at the time of actual deployment. Thanks for the reply....
edaindia wrote:
Is there any way to do this?
Yes. Loop through all the assemblies in your domain, enumerate all classes within that assembly and check what they are made (derived) of. Will that get you a list of all exceptions that can be thrown? Well, yes and no: it will give you a list of known exception-classes. Some classes might be generated at runtime, some are wrapped in global classes and only carry a cryptic number from the filesystem. Another point would be that you'd have some exceptions on that list that would be very rare. In other words, you'd end up with misleading information - preparing for StackOverflow-exceptions that simply never occur.
edaindia wrote:
My concern was about finding those sections of code which should be within a try catch block, but are not.
With all respect, that's the programmers' own responsibility. You don't want an "on error resume next" system, and you don't want to force a user into deciding "ignore", "retry" and "cancel" for a StackOverflow. They'll get confused. I find myself often clicking the X-button in such a situation.
edaindia wrote:
A global exception handler would be my last resort at the time of actual deployment.
Make it the first resort, and log everything that happens. Followup on everything, untill they slowly die out. You can't avoid falling down, there will always be an exception that you didn't cater for. Or worse, a method that fails without throwing an exception. You don't want a customer relying on a backup that failed silently! Once that you know that there will be an unhandled exception, your best option is to divine a strategy to handle them. Ie, implement that global exception-handler, and follow up on those rare exceptions that could actually harm your clients. Think about it; what you're suggesting is closed to the default behaviour of a .NET application. It makes sense to shut-down the application, since there's an exception. And there's no way that you're going to surround each and every method with a OutOfMemoryException - some things can be translated to a simple message from a global point.
edaindia wrote:
Hence the emphasis on finding a formal way to identifying all code sections which can throw an exception and resolving them through a code review.
Sounds rathe
-
edaindia wrote:
a list of all possible exceptions
No. FYI: The list of things that can go wrong in Windows would be infinite. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Merry Christmas and a Happy New Year to all.
Isn't that called StackOverflow?
Never underestimate the power of human stupidity RAH
-
I am testing a c# application and one of the issues I am finding is the application throws unhandled exception error once in a while which leads to a debug and fix cycle.... Is there a way to get a list of all possible exceptions that can be thrown by the application and the line number where it can be thrown.... Regards Ajay
No.