I want to create a bunch of errors. each specific to its own class and module. Then i would like to attach the id to an exception so when my msg change the id is still the same. How do i create this list of errors without maintaining a large global enum ?
Share
Divide the unsigned 32-bit hexadecimal number range up as a hierarchy:
where:
Then you can have 0 to 0xFF (256) modules, and 0 to 0xFFF (4096) each of classes and errors, and you only have to ensure that each error is unique to its class, and each class is unique to its module, so you don’t have to keep all error messages in a single giant table.
Example:
That’s module 04, class 01D, error 00A.