Find uncaught Exeptions |
|
Hi,
is there a way to find uncaught exceptions globally/per method? Thanks, Ingmar |
||||||||||||
|
Site Admin
|
Exceptions are raised in Run-Time (e.g. while your scripts are running) and you can test your code in order to see if they are properly handled.
Certainly you can statically (without any execution) analyze your scripts in order to find out where the exceptions are generated and where they are caught, but in-general it's very hard to say if all possible combinations are properly handled and no one exception could be left uncaught. I think it's easier to generate test-cases with adequate code coverage, run them and analyze the results. |
||||||||||||
_________________ The PHP IDE team |
Site Admin
|
no, with dynamic languages like php it's hardly possible to analyze code branches and find the exceptions that aren't properly cautch in particular. Because of php's type-less nature, it's almost always unknown what class instances are stored in the variables. Sometimes it's not even known what methods are called. Just for example:
|
||||||||||||||
_________________ The PHP IDE team |
|
Well, but if it looked like this:
, I should be able to scan my project folder for calls to A() that don't catch SpecialException, shouldn't I? Of course I'm screwed when it comes to things like dynamic method naming, but the exception converage of static code would be of great help. Especially if you could also ask for cases of too general exception handling like
|
||||||||||||||||||
|
Site Admin
|
Well, there are two distinct perspectives, the caller's and the callee's. When you see a particular method, you always know whether it can generate an exception and it's not cautch locally. So you just need to see where this method is called from. It's where you get all the problems with unknown methods/unknown classes. With my example, you can not be sure that method called in the function A is not the method that generates an exception. Well, even if you know method name, it's not helpful because you need classname too and it's problematic with many PHP code available from many php libraries/frameworks/cms. |
||||||||||||||
_________________ The PHP IDE team |
|
You are still true about 'your case' that implies dynamic object generation, but if 'my case' would be covered, I'd already be pretty happy. Meaning, that all instances of code that's explicitly calling A(), which do not handle SpecialException, get reported to me.
|
||||||||||||
|
Site Admin
|
ok. What's about all instances of code that call these instances of code calling A()? For example:
Should B() be found as non-handling SpecialException generated by A? |
||||||||||||||||
_________________ The PHP IDE team |
|
In this case, no. But in this case, D would be spotted:
The system would have to find any throwing of an Exception and traverse all the way up. |
||||||||||||||||
|
Site Admin
|
thanks, It's clearer now.
|
||||||||||||
_________________ The PHP IDE team |
Find uncaught Exeptions |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by