Add-Ons & Services

Feature Idea (exceptions and asserts)

A general discussion forum.

Feature Idea (exceptions and asserts)

Postby ivannp » 06 Aug 2014, 17:07

Was adding a new Exception and had to add a C++ file just for the POCO_IMPLEMENT_EXCEPTION. Otherwise, my class was header file only, but I don't think I could have had both POCO_DECLARE_EXCEPTION and POCO_IMPLEMENT_EXCEPTION in it.

I think what might be useful is to have POCO_DEFINE_EXCEPTION, which both declares and implements an exception - the way it would look like in a header file. To make things more flexible, one can also consider adding "inline" (POCO_IMPLEMENT_EXCEPTION_INLINE) version for POCO_IMPLEMENT_EXCEPTION, which adds the "inline" keyword to all methods - something useful for headers as well (POCO_DECLARE_EXCEPTION followed by POCO_IMPLEMENT_EXCEPTION_INLINE would have had similar effect as the suggested POCO_DEFINE_EXCEPTION).

Another useful feature is having a message (string) when asserting - I use that often. It seems that what's needed is corresponding versions of poco_assert_msg and poco_assert_msg_dbg - the AssertionViolationException can handle extra text, right?

If you think the above are useful, but don't have time to prepare the code - let me know, I can prepare a patch.

Posts: 1
Joined: 06 Aug 2014, 16:53

Re: Feature Idea (exceptions and asserts)

Postby alex » 08 Aug 2014, 04:30

Generally speaking, we do header-only code only for templates, otherwise separate headers from implementation so user can benefit from full advantage of dynamic libraries.. Assert proposal sounds fine to me. Send a github pull request and we'll look into it.
Posts: 1115
Joined: 11 Jul 2006, 16:27
Location: United_States

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest