inspect for throws

I

Ian Lazarus

Hello,

How do I analyze my code to determine which routines throw? Are there tools
which automate this? Manual inspection is prone to error.

Thanks
 
D

Dave

Ian Lazarus said:
Hello,

How do I analyze my code to determine which routines throw? Are there tools
which automate this? Manual inspection is prone to error.

Thanks

Yep, it is prone to error and I don't know of any tools (but they may very
well be out there).

You'd have to make a complete call graph of your app., including calls to
any standard library or third-party functions. Getting the set of
exceptions that can propagate out of standard / third-party libraries and
into your code will probably be a pain in the butt!

Start at the bottom (i.e. the lowest level functions called) and propagate
up the tree the exceptions that can be thrown. At each node in your tree,
eliminate any exceptions which can propagate into a function but can't
propagate out because they are handled and not re-thrown. Any place you get
to a function that has an exception specification, don't allow anything but
the exceptions in the specification to go up past that point in your tree
(assuming your compiler supports exception specifications). And if you do
find yourself cutting out some potential exceptions in this manner, that's a
spot where your program has the potential to just die at runtime if such an
exception makes it into that function and can't continue propagating because
of the exception specification.

I hope someone else can give you more easily-implementable advice...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top