Reputation: 1269
I am designing a c++ exception class.
I am planning to add following things
1>Debug flag(by default false) 2>Debug Message
During development, unit testing and debugging, this debug flag will be true. Hence this will print all necessary details in the log file ( and also in output).
Is it a good design or should I remove those extra code( which will never be used after deployment) ?
Is there any standard or design pattern or template available for designing c++ exception class ?
Upvotes: 1
Views: 99
Reputation: 96291
I would keep the exception the same between production and debug. I don't see any need to give it different functionality, but you won't be testing your production code in your debug builds then.
Make sure first that your exceptions are really exceptions. Then, if one happens during development you can just slap on your debugger and see what happened. Make sure of course that the what
method provides a suitable amount of information and leave it the same throughout the development lifecycle.
As noted in another another it's a sound idea to inherit from std::exception
.
Upvotes: 1
Reputation: 753
The good idea while creating an exception class is to derive it from std::exception.
Upvotes: 0