I am designing a software that has two logical layers, say A and B. Layer B has set of objects (classes). Layer A uses set of APIs exposed by layer B objects for information retrieval. I want to design a generic error interface across layer B objects that can be exposed to layer A. What would be the best way to write a generic error interface ?
Would adding enums for error interfacing suffice ?
Also,
For sample signature for Layer B APIs can be one of following:
error_interface Sample_API(args, void *return_value);
OR
(This is return value)void * sample_API(args, error_interface *err);
Which one of the following two signatures would be preferred ? & Why ?
Adding to this,
There will be few error codes those will be common for all layer B objects. Few error codes will be specific to some of B objects. How to create error hierarchy here ? I guess enums can not be used for creating error hierarchy ? Does creating error class hierarchy good idea ?