I am building a C# project and at some point I encounter an ErrorCode
in an exception:
try {
...
} catch (HttpListenerException e) {
if (e.ErrorCode == 995) {
}
}
this works, but what I want to both make my code more readable, as well as to avoid "magic constants", is something like this (using the error code names):
try {
...
} catch (HttpListenerException e) {
if (e.ErrorCode == ERROR_OPERATION_ABORTED) {
}
}
How can I achieve that?