C++ own exception practices -
i'm new c++ exceptions , not quite sure how should use them. i'm open every exception handling practice, of ideas.
i've rewritten c libraries custom hardware uses posix api accessing gpios, i2c, uart , network sockets. i'm trying find exception design library of custom hardware , interfaces mentioned above.
current design:
- own exceptions every interface, e.g.
customhwexception
,gpioexception
,i2cexception
, ... - embed additional information every exception (some common base class)
- "port" number, can used logging , exception handling (while "port" can number interface number, real port number, pin number, etc.):
gpio12
,i2c0
,ttys0
,port 32000
- error message (string) logging
- fatal / non fatal
- possible fix problem: e.g. none, try again later, reset interface, ...
- "port" number, can used logging , exception handling (while "port" can number interface number, real port number, pin number, etc.):
what i've read exceptions far should make our lives easier , don't think errnos embedded in exceptions add real value. user gets errno , has decide what's best him in exceptional situation. isn't better library developer knows hardware , common problems decides user should in case of error (fix)?
i'm not sure if it's idea have exception every interface. better catch exceptions of low level interfaces in (higher level) library , throw higher level exception customhwexception
? wouldn't lead mixture of code , error handling in library?
how implement this?
Comments
Post a Comment