By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

inspect for throws

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Ian Lazarus" <no****@nowhere.net> wrote in message
news:Xf***********************@bgtnsc04-news.ops.worldnet.att.net...
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...
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.