c++


Macro to define custom exception type - Bad Practice


Is using a c macro like the below to define an exception bad practice?
#define CUSTOM_EXCEPTION(name, msg) class name : std::exception { \
virtual const char* what() const throw() { \
return #msg; \
} \
};
I kind of like the idea of using a macro, because DRY, but I've heard bad things about using macros making code unmaintainable. Is there a better way to define a simple type macro returning a custom message?

Related Links

Call derived method from outside starting from base instance
What is the difference betwen these function calls that return pointers? [closed]
create Macro to collect token (parameter) into a list, one by one
Finding the minimum value in an array (What's wrong with my code?)
pulling out unique_ptr from unique_ptr<T,Deleter>
Remaining days in a Year
error: expected unqualified-id before 'while'|
Can I tell gcc to limit its “detected during” depth?
SFINAE together with auto-deduced return type and variadic templates
QT Changing pixmap each frame
Printing the Key of Node by Tail Pointer
How do I create a Slider in FLTK with multiple handles?
Determining the number of threads in Android NDK multithreading programming
Clang using LibTooling Rewriter to generate new file?
inline assembler in gives c2400 in vs 2015
qt 5.8 sql connection error:QMYSQL driver not loaded on windows 10

Categories

HOME
c++
iframe
scenekit
speech-recognition
graph-algorithm
soundcloud
spark-dataframe
datepicker
rhel
executable-jar
emu8086
postgresql-9.0
border
web-component
httpsession
selenium-rc
google-nativeclient
u2
kafka-python
android-ffmpeg
vim-syntax-highlighting
hp-quality-center
post-build-event
word
yamldotnet
polymer-serve
tail-recursion
umbraco-mvc
war
digestive-functors
binary-image
pywinusb
reduce
enterprise-library-6
family-tree
rufus-scheduler
tiles
fluentbootstrap
inputstreamreader
terminal-emulator
object-oriented-analysis
wso2dss
equation-solving
django-media
smartmeter
hasownproperty
leap-motion
cpio
outlook-2016
dbx
code-collaborator
python-wheel
smf
jodconverter
nsthread
qtquick2
numerical-analysis
classname
f#-interactive
phpinfo
dfdl
zodb
integer-overflow
tess-two
android-context
adobe-dps
foundation
xlet
authentication-flows
unexpectendoffile
protractor-net
fswatch
glut
pysftp
cpanm
setlocale
openni
dynamicquery
ngen
allocation
networkcredentials
arbitrary-precision
sqr
mux
firstdata
svggraph
mashup
qglviewer
nodejitsu
tiles2
iunknown
badimageformatexception
ipad-2
converters
memory-mapped-files
system-design
ext-direct
plcrashreporter
iphone-sdk-3.0
scalaquery
endl
css-parsing
eda
rebuild
stack-unwinding
duck-typing
installshield-2008
jquery-ui-plugins
remote-administration

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile