Proposal: define exceptions when !JSON_USE_EXCEPTION

The current behavior of only defining these classes when exceptions are enabled creates difficulties for large projects with trees of dependencies.

OSS libraries will often reasonably try/catch on these exceptions, which causes those libraries not to build when !JSON_USE_EXCEPTION.  This is easy to miss in those libraries, which don't test for nonstandard configurations of their dependencies, but it makes those libraries difficult to use in projects with large dependency trees that have already configured jsoncpp in this way.
This commit is contained in:
vslashg 2022-11-16 10:40:29 -05:00 committed by GitHub
parent 8190e061bc
commit 53a0f1dec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,7 +60,6 @@
*/ */
namespace Json { namespace Json {
#if JSON_USE_EXCEPTION
/** Base class for all exceptions we throw. /** Base class for all exceptions we throw.
* *
* We use nothing but these internally. Of course, STL can throw others. * We use nothing but these internally. Of course, STL can throw others.
@ -96,7 +95,6 @@ class JSON_API LogicError : public Exception {
public: public:
LogicError(String const& msg); LogicError(String const& msg);
}; };
#endif
/// used internally /// used internally
JSONCPP_NORETURN void throwRuntimeError(String const& msg); JSONCPP_NORETURN void throwRuntimeError(String const& msg);