D
darylew
I've defined an input operator for my compound type. The operator reads ineach component, and any applicable delimiters. I check the stream state after each read. I'm wondering what to do after all the components are read..
I have a function to create an object given a list of components. It has aspecial set of exception classes to throw if an invalid combination of components are given. I'm figuring to have my input operator catch those exceptions, turn on the "fail" flag, then re-throw if "fail" is marked as a throwable offense. (You have to suppress the automatic throwing that could happen if a flag is set, since you what to re-throw your own error instead ofa new std::ios_base::failure object.) A bad combination of components could have theoretically picked-up before the source object is created, so it counts as a parsing error, implying the "fail" flag.
But what should happen for other exceptions? The only way my new object can create other types of exceptions is if the component-level assignments fail. I've read some stuff that seems to indicate that the "bad" flag shouldbe set and the exception re-thrown if "bad" is marked as a throwable offense. But I was thinking of doing nothing; it's not the stream's fault that assignment failed, and the new components were valid, so the I/O stream should let the exception through without any changes.
Daryle W.
I have a function to create an object given a list of components. It has aspecial set of exception classes to throw if an invalid combination of components are given. I'm figuring to have my input operator catch those exceptions, turn on the "fail" flag, then re-throw if "fail" is marked as a throwable offense. (You have to suppress the automatic throwing that could happen if a flag is set, since you what to re-throw your own error instead ofa new std::ios_base::failure object.) A bad combination of components could have theoretically picked-up before the source object is created, so it counts as a parsing error, implying the "fail" flag.
But what should happen for other exceptions? The only way my new object can create other types of exceptions is if the component-level assignments fail. I've read some stuff that seems to indicate that the "bad" flag shouldbe set and the exception re-thrown if "bad" is marked as a throwable offense. But I was thinking of doing nothing; it's not the stream's fault that assignment failed, and the new components were valid, so the I/O stream should let the exception through without any changes.
Daryle W.