summaryrefslogtreecommitdiff
path: root/src/shared/windows_error.cpp
diff options
context:
space:
mode:
authorBrian Munro <brian.alexander.munro@gmail.com>2018-02-22 18:02:02 +0200
committerGitHub <noreply@github.com>2018-02-22 18:02:02 +0200
commit28714f0eb800f2170acbf29dddce1582d20d6b8b (patch)
tree0684c123db375336e0e03f0240155a12e744db16 /src/shared/windows_error.cpp
parent0bcd752b2758bdb072b498ccc90905276be065e9 (diff)
parent5e5c9c07291f6b09623d31c92b1fb61c4ede576e (diff)
Merge pull request #236 from SuperSandro2000/new_vfs_library
Update reame.md
Diffstat (limited to 'src/shared/windows_error.cpp')
-rw-r--r--src/shared/windows_error.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/shared/windows_error.cpp b/src/shared/windows_error.cpp
index 97a58a20..ab5c7b8e 100644
--- a/src/shared/windows_error.cpp
+++ b/src/shared/windows_error.cpp
@@ -22,28 +22,27 @@ 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