I am working on a client server based communication protocol stack.
I have a list of errors that could occur during the course of communication
Like,
Code:
Errortype [1]
Type1 [0]
Type2 [1]
Type1
Subtype1 [0]
Subtype2 [1]
Type2
Subtype3 [0]
Subtype1
cause1 [0]
cause2 [1]
cause3 [2]
Subtype2
cause4 [0]
Subtype3
cause5 [0]
cause6 [1]
cause7 [2]
cause8 [3]
So, if the server finds an error in connection due to cause7 of subtype3
and type2, it has to send the error report as:
Code:
errortype : 0x01
Type : 0x01
Subtype : 0x00
Cause : 0x02
So the data transferes is 01 01 00 02
I found that i can't have enum of enums in c++. And other suggestion I got
was to used a 4 byte integer for the whole error structure, so that the most significant 8 bit will show errortype, the next 8bit shows type, the next shows subtype and the least significant 8 bit shows cause. Is there any better way to do it, so that the types and subtypes and cause don't get mixed up, like type2 an't have subtype1 cause1.?