Timeline for Technique to synchronize error codes in a same-project-API
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 23, 2015 at 13:22 | comment | added | bgusach | We are getting tricky here, but it is not about the readability, but the mapping numbers->error reasons, i.g. {33: 'resource_not_found'}. My idea was, that when the c# code hits the error case, instead of just returning 33, it think: ok, I have a 'resource_not_found' (which is arbitrary as well, but more programmer-readable), so let's look up what I have to return... 33? ok, there you go. | |
| Feb 23, 2015 at 13:17 | comment | added | Avner Shahar-Kashtan | Yes, this is what I was going for: the C# process returns error 33, which means resource not found. It doesn't care about readable strings or display - just the logical meaning of the error code. It's the client application ("client" here meaning "app that displays or writes human-readable data") to translate it to something readable. | |
| Feb 23, 2015 at 13:15 | comment | added | bgusach | The c# process returns the codes, of course. The thing is that the conceptual mapping of "33 means resource not found" has to be shared by both parties, which may lead to inconsistence issues. Maybe I am misunderstanding how the APIs should work, and the C# should not care at all about who is calling it (if it was an external 3rd party, this would be the case actually). | |
| Feb 23, 2015 at 12:59 | comment | added | Avner Shahar-Kashtan | I might be missing something, but I understood that the C# process returns the errors, and thus is, by necessity, returning a set number of possible errors, because this process is where the business logic happens. | |
| Feb 23, 2015 at 12:56 | comment | added | bgusach | But this still binds an arbitrary number with the meaning of the error code. For instance, the C# code will return the number 33, meaning that "resource could not be found". This (implicit) binding of numbers and explanations is still duplicated on both sides. However, your idea is good with some minor changes. I can use a mapping between error labels and numbers, like {'resource_not_found: 33}, and if the error shows up, the C# process can look up the label and return the code. | |
| Feb 23, 2015 at 9:30 | history | answered | Avner Shahar-Kashtan | CC BY-SA 3.0 |