#include <winstl/error/last_error_scope.hpp>
DWORD err = ::GetLastError(); { winstl::last_error_scope scope; // Scope the error while we change it // Some code that changes (or may change) the last error . . . ::SetLastError(ERROR_ACCESS_DENIED); // ... we just do this for pedagogical purposes } // End of scope - error value replaced to former value assert(::GetLastError() == err);
Public Types | |
Types | |
typedef last_error_scope | class_type |
Public Member Functions | |
Operations | |
last_error_scope () throw () | |
Takes a copy of the current thread error, which will be reset on destruction of this instance. | |
last_error_scope (ws_dword_t dwErr) throw () | |
Takes a copy of the current thread error, which will be reset on destruction of this instance. | |
~last_error_scope () throw () | |
Resets the thread error value current at the epoque of construction of this instance. | |
Operations | |
operator ws_dword_t () const | |
Returns the value of the recorded thread error, which will be reset on destruction of this instance. |
last_error_scope | ( | ) | throw () [inline] |
Takes a copy of the current thread error, which will be reset on destruction of this instance.
last_error_scope | ( | ws_dword_t | dwErr | ) | throw () [inline, explicit] |
Takes a copy of the current thread error, which will be reset on destruction of this instance.
The current thread error is set to the given value.
dwErr | The value to which the current thread error is set |
~last_error_scope | ( | ) | throw () [inline] |
Resets the thread error value current at the epoque of construction of this instance.
operator ws_dword_t | ( | ) | const [inline] |
Returns the value of the recorded thread error, which will be reset on destruction of this instance.