-
Notifications
You must be signed in to change notification settings - Fork 13
[feature-request] Define behaviour of error conditions, handling, and passing #85
Comments
Considering that the trigger for this discussion is a very specific method and the error is set during the register access, I would not remove the setting of the error key in the register access methods. A better (and rather simple) solution to me would be to provide a method to remove/revoke key setting. This requires small changes to the RPCSvc code which has to be agreed (and propagated to) UW. |
Well there was a discussion in the design of the GBT functions directly; and in some sense I think the design of those functions was limited because of how the It seems like having to check if an error key should be removed (particularly when this amount of checks could grow inside nested loops) is not ideal and could introduce unwanted processing time on the Zynq. Rather than relying on UW to change the |
What types of errors do we want to handle. I think this is the biggest question. The following come to mind:
And Example 4: One additional exception that could arise, and be recovered automatically, in my view is a loss of sync of the front-end. This could be assigned if a bus error occurs and the corresponding sync_error_counter is nonzero (we could also subdivide this into the case where the bus error is generated but the sync_error_counter is 0x0). We might consider this being automatically handled by issuing a link reset (
We also have the "Node Not Found" or "Address Not Found" cases. But I am not sure if those warrant handling as they are probably an indication of either 1) bad design by developer (e.g. trying to access a non-existent node) or 2) bad backend configuration (e.g. wrong address table, lmdb, fw version, etc...).
I think if we provide 4 separate type of exceptions for the cases above we would not need to parse the string. Alternatively the error string could just be made to include a keyword that is the type of error message above (see table above for keyword suggestions).
The following functions or error handling comes to mind:
Just some thoughts on the matter. Hopefully they are constructive. |
I disagree here. It doesn't matter if you check whether you want to set the
They should not. The proposed change adds functionality while not touching anything beyond it.
While this is a possible solution, one should not forget that such change will introduce check on whether the |
I was thinking about the added time for one set of transactions (e.g. read N_OH's * N_VFAT's). But this is probably a much smaller added time than the case you outlined below (e.g. checking if
Yes indeed that would be bad.
I am not opposed to this idea (adding to the |
One more consideration: actually an |
Yes if we went this route the caller code would need to always check and parse the error message; and we should adopt some standardisations for this error message. |
(Started writing this but had to leave, so this may not be salient any longer)
This is a bad way to go, as it will break some common API things that we have already worked hard to establish (a common interface viz the The point I think we should keep in mind here is that exceptions (loosely defined) can propagate on the card, and on the host PC, but not between. It is for this reason (and this reason alone, as far as I understand) that we have the
Can you provide current (or potential) examples of this? Because I want to understand if the current handler now can be adapted to handle this generically, or if it would need a case-by-case treatment. I preferred the generic handler route because it avoids adding 15 lines of code for every RPC call... The goal here should be robust operation coupled with clear delineation of error conditions. |
During the GBT module writing, it was not especially easy to write functions where all return codes were checked. So, I also began to think about exception handling. Here are some of the reflections I had about :
auto exportRPCMethod(std::function<uint32_t(LocalArgs &la)> func){
auto return_function = [=](const RPCMsg *request, RPCMsg *response)
{
CREATE_LOCAL_ARGS();
try {
function_return_value = func(la);
// Fill a special RPC key with the return value
}
catch (const std::exception& e) {
// Fill special RPC keys
}
}
return return_function:
}
static auto writeGBTConfig_EXPORTED = exportRPCMethod(writeGBTConfig); // Could be a macro
uin32_t writeGBTConfig(LocalArgs &la) {
...
}
/* in module_init() */
modmgr->register_method("gbt", "writeGBTConfig", &writeGBTConfig_EXPORTED);
uint32_t readReg(localArgs * la, const std::string & regName);
bool readReg(localArgs * la, const std::string & regName, uint32_t ®Value) noexcept; Such functions would solve the "GBT case" as well as all other cases where one would rely on errors for proper operation.
|
A few comments:
Moreover, what needs to drive this is the actual contract the functions are asked to enforce.
|
Brief summary of issue
This issue will attempt to normalize and define how errors are handled inside the CTP7 modules and corresponding RPC error keys.
Types of issue
Considerations
error
key is set, then the thing making the RPC call should expect that there was a failure that couldn't be handled inside the method itself.error
key), or handled based on the error in the function itself.error
key messages should be done; incmsgemos
my current implementation is throwing an exception if theerror
key exists, and populating the exception with the message.error
message string (it simply assumes that things that could be handled were, and now it just needs to alert that things are not right)error
message encodes something that could be parsed in the calling code and trigger some action, one would then have to parse the exception (not really a problem)The text was updated successfully, but these errors were encountered: