[Boost-users] [Test] prevent exceptions from beeing caught

586 views
Skip to first unread message

Jan Rudoszanski

unread,
Apr 27, 2010, 6:26:01 PM4/27/10
to boost...@lists.boost.org
Hi

Is there any possibility for boost.test execution_monitor to not to
catch exceptions thrown from code that I'm examining in a test case?
It's the case with system errors which you can pass from execution
monitor outside, to the system for further examination in debugger
(--catch_system_errors=n). How am I supposed to do the same with
regular exceptions i.e. detect where an exception comes from, if only
information I get is something like "unknown location(0): fatal error
in testValidate" etc? I would love to have possibility to detect this
exception with debugger and print full stack trace, examine variables
and so on. Is it possible with boost.test?

Regards.
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

--
You received this message because you are subscribed to the Google Groups "BOOST Archives" group.
To post to this group, send email to boost...@googlegroups.com.
To unsubscribe from this group, send email to boost-list+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boost-list?hl=en.

Gennadiy Rozental

unread,
Apr 28, 2010, 12:39:25 AM4/28/10
to boost...@lists.boost.org
Jan Rudoszanski <jan.rudoszanski <at> gmail.com> writes:

>
> Hi
>
> Is there any possibility for boost.test execution_monitor to not to
> catch exceptions thrown from code that I'm examining in a test case?

Boost.Test does not prevent you from catching any exceptions. You can always say
'catch throw' and it will stop at first exception being throw.

Also I am not sure in general what do you expect to happened in case if
Boost.Test let's say do not catch your exception. How would it miraculously let
you know where exception comes from?

What I do recommend is to use Boost.Exception. These comes along with file+line
where it being thrown from.

Gennadiy

Jan Rudoszanski

unread,
Apr 28, 2010, 3:28:11 AM4/28/10
to boost...@lists.boost.org
Hi

Thanks for your reply!

>>     Is there any possibility for boost.test execution_monitor to not to
>> catch exceptions thrown from code that I'm examining in a test case?
>
> Boost.Test does not prevent you from catching any exceptions. You can always say
> 'catch throw' and it will stop at first exception being throw.
>
> Also I am not sure in general what do you expect to happened in case if
> Boost.Test let's say do not catch your exception. How would it miraculously let
> you know where exception comes from?

It's not a miracle its a debugger I'm saying about. I said that
before. Just as I can "catch" a system error in GDB when running my
test program under it, I would like to let debugger care for my
uncaught exception. In such case GDB points me to the exact place
where this particular exception was thrown, and additionally I have
full stack trace and I can inspect every variable. It's like you throw
an exception from main, and don't have any "catch" statements (I use
GDB for debugging, maybe other debuggers/OS'es behave differently?).

> What I do recommend is to use Boost.Exception. These comes along with file+line
> where it being thrown from.

Good point. I'll tr it right away.
Thanks

John Wilkinson

unread,
Apr 28, 2010, 9:25:02 AM4/28/10
to boost...@lists.boost.org
Have you tried setting a catchpoint to stop execution when the exception is thrown? (http://www.delorie.com/gnu/docs/gdb/gdb_31.html)

John
This e-mail message and any attachment(s) transmitted with it are intended only for the
use of the recipient(s) named above.This message may be privileged and/or confidential.
If you are not an intended recipient, you may not review, copy or distribute this message.
If you have received this communication in error, please notify us immediately by e-mail
and delete the original message.

Jan Rudoszanski

unread,
Apr 28, 2010, 11:57:45 AM4/28/10
to boost...@lists.boost.org
On Wed, Apr 28, 2010 at 3:25 PM, John Wilkinson <jwilk...@tsystem.com> wrote:
> Have you tried setting a catchpoint to stop execution when the exception is thrown? (http://www.delorie.com/gnu/docs/gdb/gdb_31.html)
>
> John

This is exactly what I wanted to achieve! Worked perfectly. Thanks John!

Gennadiy Rozental

unread,
Apr 28, 2010, 12:31:40 PM4/28/10
to boost...@lists.boost.org
Jan Rudoszanski <jan.rudoszanski <at> gmail.com> writes:

> Just as I can "catch" a system error in GDB when running my
> test program under it, I would like to let debugger care for my
> uncaught exception.

As mentioned in other post catch throw should work with and without Boost.Test.

Gennadiy
Reply all
Reply to author
Forward
0 new messages