I am currently involved in the development of a low-level network application. Recently, we have encountered the problem of error messages both for the userโs land and for debugging. Given that some errors can be triggered from functions of a lower level, libraries ... report that the exact error status (code, messages, env ...) from one layer to another higher level showed that it is somewhat cumbersome .
However, we decided to return to using exceptions, but recently a friend came up with this approach: Using the Error_Buf class, which contains enough information about what causes an error such as an error code, a buffer message, and passing it as a parameter to a function. Therefore, whenever something goes wrong, an adequate message and error code are set, for example, to error-> buffer and error-> error_code, and then they are sent back to the calling function and the corresponding return value is sent.
This is actually what we use in c (at least libnet does something similar), but how close or far is it from efficiency and reliability, code support can be a problem too.
Thank,
source
share