Opened on 07/16/2014 at 01:13:23 PM
Last modified on 12/07/2014 at 10:53:29 PM
#1060 new change
Use system_error mechanism
Reported by: | sergz | Assignee: | |
---|---|---|---|
Priority: | P4 | Milestone: | |
Module: | Adblock-Plus-for-Internet-Explorer | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Platform: | Internet Explorer | |
Ready: | yes | Confidential: | no |
Tester: | Verified working: | no | |
Review URL(s): |
Description
Background
In the project there are several domains of the runtime errors, at least
- from std classes
- based on Windows API GetLastError()
- our own domain, unexpected value of some input arguments, or some state is inconsistent, like pipe became closed, which is basically should be GetLastError()
Fortunately, now there is a standard way to handle different errors uniformly.
What to change
First of all we should fix the usage of GetLastError(). GetLastError() should be called before anything else. At least now we are creating some strings which involves memory allocation, which can modify the result of GetLastError().
We have to have custom error_category (C++11) for GetLastError(). Since we are not going to create the insane enum for all Windows error codes and properly implement the equivalence, so only implement partially (name, message (based on FormatMessage)) error_category and the factory method (which should not be available using ADL, something like std::error_code makeWinErrorCode(int code);).