summaryrefslogtreecommitdiff
path: root/src/shared/windows_error.cpp
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2018-02-23 01:45:58 +0100
committerSandro Jäckel <sandro.jaeckel@gmail.com>2018-02-23 01:45:58 +0100
commitea6292168a6acd4c263913f0ccd7dd64daf4f5cf (patch)
tree312024abbd7c3c100274f3a8031d49096480b654 /src/shared/windows_error.cpp
parent5e5c9c07291f6b09623d31c92b1fb61c4ede576e (diff)
Revert "Applied clang-format on source"
This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e.
Diffstat (limited to 'src/shared/windows_error.cpp')
-rw-r--r--src/shared/windows_error.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/shared/windows_error.cpp b/src/shared/windows_error.cpp
index ab5c7b8e..97a58a20 100644
--- a/src/shared/windows_error.cpp
+++ b/src/shared/windows_error.cpp
@@ -22,27 +22,28 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-std::string windows_error::constructMessage(const std::string& input, int inErrorCode) {
- std::ostringstream finalMessage;
- finalMessage << input;
+std::string windows_error::constructMessage(const std::string& input, int inErrorCode)
+{
+ std::ostringstream finalMessage;
+ finalMessage << input;
- LPSTR buffer = nullptr;
+ LPSTR buffer = nullptr;
- DWORD errorCode = inErrorCode != -1 ? inErrorCode : ::GetLastError();
+ DWORD errorCode = inErrorCode != -1 ? inErrorCode : ::GetLastError();
- // TODO: the message is not english?
- if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, errorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
- finalMessage << " (errorcode " << errorCode << ")";
- } else {
- LPSTR lastChar = buffer + strlen(buffer) - 2;
- *lastChar = '\0';
- finalMessage << " (" << buffer << " [" << errorCode << "])";
- LocalFree(buffer); // allocated by FormatMessage
- }
+ // TODO: the message is not english?
+ if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
+ finalMessage << " (errorcode " << errorCode << ")";
+ } else {
+ LPSTR lastChar = buffer + strlen(buffer) - 2;
+ *lastChar = '\0';
+ finalMessage << " (" << buffer << " [" << errorCode << "])";
+ LocalFree(buffer); // allocated by FormatMessage
+ }
- ::SetLastError(errorCode); // restore error code because FormatMessage might have modified it
- return finalMessage.str();
+ ::SetLastError(errorCode); // restore error code because FormatMessage might have modified it
+ return finalMessage.str();
}
} // namespace MOShared