Index: src/libchcore/TCoreWin32Exception.h =================================================================== diff -u -N -r8aaaa0a6febeeeb6dc7d93b859b58488c54ba5e6 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TCoreWin32Exception.h (.../TCoreWin32Exception.h) (revision 8aaaa0a6febeeeb6dc7d93b859b58488c54ba5e6) +++ src/libchcore/TCoreWin32Exception.h (.../TCoreWin32Exception.h) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -21,12 +21,6 @@ #include "TCoreException.h" -#define THROW_CORE_EXCEPTION_WIN32(error_code, win32_error_code)\ - throw chcore::TCoreWin32Exception(error_code, win32_error_code, L"", __FILEW__, __LINE__, __FUNCTIONW__) - -#define THROW_CORE_EXCEPTION_WIN32_MSG(error_code, win32_error_code, msg)\ - throw chcore::TCoreWin32Exception(error_code, win32_error_code, msg, __FILEW__, __LINE__, __FUNCTIONW__) - namespace chcore { class LIBCHCORE_API TCoreWin32Exception : public TCoreException Index: src/libchcore/TDateTime.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TDateTime.cpp (.../TDateTime.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TDateTime.cpp (.../TDateTime.cpp) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -49,7 +49,7 @@ m_tTime = _mktime64(&tTime); if (m_tTime == -1) - THROW_CORE_EXCEPTION_WIN32(eErr_InvalidArgument, GetLastError()); + throw TCoreWin32Exception(eErr_InvalidArgument, GetLastError(), L"Cannot make time", LOCATION); } TDateTime::TDateTime(FILETIME ftDateTime) @@ -72,11 +72,11 @@ // convert and process as system time FILETIME tLocalFileTime; if (!FileTimeToLocalFileTime(&ftDateTime, &tLocalFileTime)) - THROW_CORE_EXCEPTION_WIN32(eErr_InvalidArgument, GetLastError()); + throw TCoreWin32Exception(eErr_InvalidArgument, GetLastError(), L"Cannot convert file time to local file time", LOCATION); SYSTEMTIME sysTime; if (!FileTimeToSystemTime(&tLocalFileTime, &sysTime)) - THROW_CORE_EXCEPTION_WIN32(eErr_InvalidArgument, GetLastError()); + throw TCoreWin32Exception(eErr_InvalidArgument, GetLastError(), L"Cannot convert file time to system time", LOCATION); return operator=(sysTime); } @@ -98,7 +98,7 @@ m_tTime = _mktime64(&tTime); if (m_tTime == -1) - THROW_CORE_EXCEPTION_WIN32(eErr_InvalidArgument, GetLastError()); + throw TCoreWin32Exception(eErr_InvalidArgument, GetLastError(), L"Cannot make time", LOCATION); return *this; } Index: src/libchcore/TFileException.h =================================================================== diff -u -N -r8aaaa0a6febeeeb6dc7d93b859b58488c54ba5e6 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TFileException.h (.../TFileException.h) (revision 8aaaa0a6febeeeb6dc7d93b859b58488c54ba5e6) +++ src/libchcore/TFileException.h (.../TFileException.h) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -24,9 +24,6 @@ #include "TPath.h" #include "TCoreException.h" -#define THROW_FILE_EXCEPTION(error_code, native_error_code, path, msg)\ - throw chcore::TFileException(error_code, native_error_code, path, msg, __FILEW__, __LINE__, __FUNCTIONW__) - namespace chcore { class LIBCHCORE_API TFileException : public TCoreException Index: src/libchcore/TLocalFilesystem.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -110,13 +110,13 @@ if (hFile == INVALID_HANDLE_VALUE) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotOpenFile, dwLastError, pathFileDir, L"Cannot open file for setting file/directory times"); + throw TFileException(eErr_CannotOpenFile, dwLastError, pathFileDir, L"Cannot open file for setting file/directory times", LOCATION); } if (!SetFileTime(hFile, &ftCreationTime.GetAsFiletime(), &ftLastAccessTime.GetAsFiletime(), &ftLastWriteTime.GetAsFiletime())) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotSetFileTimes, dwLastError, pathFileDir, L"Cannot set file/directory times"); + throw TFileException(eErr_CannotSetFileTimes, dwLastError, pathFileDir, L"Cannot set file/directory times", LOCATION); } } @@ -125,7 +125,7 @@ if (!::SetFileAttributes(PrependPathExtensionIfNeeded(pathFileDir).ToString(), dwAttributes)) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotSetFileAttributes, dwLastError, pathFileDir, L"Cannot set file/directory attributes"); + throw TFileException(eErr_CannotSetFileAttributes, dwLastError, pathFileDir, L"Cannot set file/directory attributes", LOCATION); } } @@ -136,7 +136,7 @@ if (!::CreateDirectory(PrependPathExtensionIfNeeded(pathDirectory).ToString(), NULL)) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotCreateDirectory, dwLastError, pathDirectory, L"Cannot create directory"); + throw TFileException(eErr_CannotCreateDirectory, dwLastError, pathDirectory, L"Cannot create directory", LOCATION); } } else @@ -159,7 +159,7 @@ { DWORD dwLastError = GetLastError(); if (dwLastError != ERROR_ALREADY_EXISTS) - THROW_FILE_EXCEPTION(eErr_CannotCreateDirectory, dwLastError, pathToTest, L"Cannot create directory"); + throw TFileException(eErr_CannotCreateDirectory, dwLastError, pathToTest, L"Cannot create directory", LOCATION); } } } @@ -171,7 +171,7 @@ if (!::RemoveDirectory(PrependPathExtensionIfNeeded(pathDirectory).ToString())) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotRemoveDirectory, dwLastError, pathDirectory, L"Cannot delete directory"); + throw TFileException(eErr_CannotRemoveDirectory, dwLastError, pathDirectory, L"Cannot delete directory", LOCATION); } } @@ -180,7 +180,7 @@ if (!::DeleteFile(PrependPathExtensionIfNeeded(pathFile).ToString())) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotDeleteFile, dwLastError, pathFile, L"Cannot delete file"); + throw TFileException(eErr_CannotDeleteFile, dwLastError, pathFile, L"Cannot delete file", LOCATION); } } @@ -209,7 +209,7 @@ else { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotGetFileInfo, dwLastError, pathFile, L"Cannot retrieve file information"); + throw TFileException(eErr_CannotGetFileInfo, dwLastError, pathFile, L"Cannot retrieve file information", LOCATION); } } @@ -220,7 +220,7 @@ DWORD dwLastError = GetLastError(); // there is also the destination path that is important; tracking that would require adding a new exception class // complicating the solution. For now it's not necessary to have that information in the exception. - THROW_FILE_EXCEPTION(eErr_CannotFastMove, dwLastError, pathSource, L"Cannot fast move file/directory"); + throw TFileException(eErr_CannotFastMove, dwLastError, pathSource, L"Cannot fast move file/directory", LOCATION); } } @@ -352,7 +352,7 @@ else { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotGetFreeSpace, dwLastError, path, L"Failed to retrieve free space information"); + throw TFileException(eErr_CannotGetFreeSpace, dwLastError, path, L"Failed to retrieve free space information", LOCATION); } } } Index: src/libchcore/TLocalFilesystemFile.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TLocalFilesystemFile.cpp (.../TLocalFilesystemFile.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TLocalFilesystemFile.cpp (.../TLocalFilesystemFile.cpp) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -67,7 +67,7 @@ if (m_hFile == INVALID_HANDLE_VALUE) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot open for reading."); + throw TFileException(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot open for reading", LOCATION); } } @@ -79,7 +79,7 @@ if (m_hFile == INVALID_HANDLE_VALUE) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot create file."); + throw TFileException(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot create file.", LOCATION); } } @@ -96,7 +96,7 @@ if (m_hFile == INVALID_HANDLE_VALUE) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot open for reading."); + throw TFileException(eErr_CannotOpenFile, dwLastError, m_pathFile, L"Cannot open for reading.", LOCATION); } } @@ -109,7 +109,7 @@ void TLocalFilesystemFile::Truncate(file_size_t fsNewSize) { if (!IsOpen()) - THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"File not open yet. Cannot truncate."); + throw TFileException(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"File not open yet. Cannot truncate.", LOCATION); // when no-buffering is used, there are cases where we'd need to switch to buffered ops // to adjust file size @@ -134,13 +134,13 @@ if (!SetFilePointerEx(m_hFile, li, &liNew, FILE_BEGIN)) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_SeekFailed, dwLastError, m_pathFile, L"Cannot seek to appropriate position"); + throw TFileException(eErr_SeekFailed, dwLastError, m_pathFile, L"Cannot seek to appropriate position", LOCATION); } if(!::SetEndOfFile(m_hFile)) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotTruncate, dwLastError, m_pathFile, L"Cannot mark the end of file"); + throw TFileException(eErr_CannotTruncate, dwLastError, m_pathFile, L"Cannot mark the end of file", LOCATION); } // close the file that was open in inappropriate mode @@ -151,7 +151,7 @@ void TLocalFilesystemFile::ReadFile(TOverlappedDataBuffer& rBuffer) { if (!IsOpen()) - THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot read from closed file"); + throw TFileException(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot read from closed file", LOCATION); //ATLTRACE(_T("Reading %lu bytes\n"), rBuffer.GetRequestedDataSize()); if (!::ReadFileEx(m_hFile, rBuffer.GetBufferPtr(), rBuffer.GetRequestedDataSize(), &rBuffer, OverlappedReadCompleted)) @@ -174,15 +174,15 @@ } default: - THROW_FILE_EXCEPTION(eErr_CannotReadFile, dwLastError, m_pathFile, L"Error reading data from file"); + throw TFileException(eErr_CannotReadFile, dwLastError, m_pathFile, L"Error reading data from file", LOCATION); } } } void TLocalFilesystemFile::WriteFile(TOverlappedDataBuffer& rBuffer) { if (!IsOpen()) - THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot write to closed file"); + throw TFileException(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot write to closed file", LOCATION); DWORD dwToWrite = boost::numeric_cast(rBuffer.GetRealDataSize()); @@ -194,14 +194,14 @@ { DWORD dwLastError = GetLastError(); if (dwLastError != ERROR_IO_PENDING) - THROW_FILE_EXCEPTION(eErr_CannotWriteFile, dwLastError, m_pathFile, L"Error while writing to file"); + throw TFileException(eErr_CannotWriteFile, dwLastError, m_pathFile, L"Error while writing to file", LOCATION); } } void TLocalFilesystemFile::FinalizeFile(TOverlappedDataBuffer& rBuffer) { if (!IsOpen()) - THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot write to closed file"); + throw TFileException(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"Cannot write to closed file", LOCATION); if (m_bNoBuffering && rBuffer.IsLastPart()) { @@ -247,14 +247,14 @@ void TLocalFilesystemFile::GetFileInfo(TFileInfo& tFileInfo) const { if (!IsOpen()) - THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"File not open. Cannot get file info."); + throw TFileException(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"File not open. Cannot get file info.", LOCATION); BY_HANDLE_FILE_INFORMATION bhfi; if (!::GetFileInformationByHandle(m_hFile, &bhfi)) { DWORD dwLastError = GetLastError(); - THROW_FILE_EXCEPTION(eErr_CannotGetFileInfo, dwLastError, m_pathFile, L"Retrieving file info from handle failed."); + throw TFileException(eErr_CannotGetFileInfo, dwLastError, m_pathFile, L"Retrieving file info from handle failed.", LOCATION); } ULARGE_INTEGER uli; Index: src/libchcore/TSQLiteSerializerFactory.cpp =================================================================== diff -u -N -r0c48142d3db406c32c05d7afdf77da45b2459b34 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TSQLiteSerializerFactory.cpp (.../TSQLiteSerializerFactory.cpp) (revision 0c48142d3db406c32c05d7afdf77da45b2459b34) +++ src/libchcore/TSQLiteSerializerFactory.cpp (.../TSQLiteSerializerFactory.cpp) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -50,7 +50,7 @@ { DWORD dwLastError = GetLastError(); if (dwLastError != ERROR_FILE_NOT_FOUND) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotDeleteFile, dwLastError); + throw TCoreWin32Exception(eErr_CannotDeleteFile, dwLastError, L"Cannot delete tasks.sqlite file", LOCATION); } } @@ -87,7 +87,7 @@ { DWORD dwLastError = GetLastError(); if (dwLastError != ERROR_FILE_NOT_FOUND) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotDeleteFile, dwLastError); + throw TCoreWin32Exception(eErr_CannotDeleteFile, dwLastError, L"Cannot delete task database file", LOCATION); } } Index: src/libchcore/TWorkerThreadController.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rad4fe0f8085b15527158073aa76eb2d9ef80b0e5 --- src/libchcore/TWorkerThreadController.cpp (.../TWorkerThreadController.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TWorkerThreadController.cpp (.../TWorkerThreadController.cpp) (revision ad4fe0f8085b15527158073aa76eb2d9ef80b0e5) @@ -33,7 +33,7 @@ { m_hKillThread = CreateEvent(NULL, TRUE, FALSE, NULL); if (!m_hKillThread) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotCreateEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotCreateEvent, GetLastError(), L"Failed to create event", LOCATION); } TWorkerThreadController::~TWorkerThreadController() @@ -59,13 +59,13 @@ // just in case reset the kill event to avoid early death of the thread to be created if (!::ResetEvent(m_hKillThread)) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResetEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotResetEvent, GetLastError(), L"Failed to reset event", LOCATION); boost::upgrade_to_unique_lock lock_upgraded(lock); m_hThread = ::CreateThread(NULL, 0, pThreadFunction, pThreadParam, CREATE_SUSPENDED, NULL); if (!m_hThread) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotCreateThread, GetLastError()); + throw TCoreWin32Exception(eErr_CannotCreateThread, GetLastError(), L"Failed to create thread", LOCATION); if (!::SetThreadPriority(m_hThread, iPriority)) { @@ -74,7 +74,7 @@ CloseHandle(m_hThread); m_hThread = NULL; - THROW_CORE_EXCEPTION_WIN32(eErr_CannotChangeThreadPriority, dwLastError); + throw TCoreWin32Exception(eErr_CannotChangeThreadPriority, dwLastError, L"Failed to set thread priority", LOCATION); } if (::ResumeThread(m_hThread) == (DWORD)-1) @@ -84,7 +84,7 @@ CloseHandle(m_hThread); m_hThread = NULL; - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResumeThread, dwLastError); + throw TCoreWin32Exception(eErr_CannotResumeThread, dwLastError, L"Failed to resume thread", LOCATION); } } @@ -103,15 +103,15 @@ if (dwRes == WAIT_OBJECT_0) { if (!::ResetEvent(m_hKillThread)) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResetEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotResetEvent, GetLastError(), L"Failed to reset event", LOCATION); boost::upgrade_to_unique_lock lock_upgraded(lock); CloseHandle(m_hThread); m_hThread = NULL; } else - THROW_CORE_EXCEPTION_WIN32(eErr_WaitingFailed, GetLastError()); + throw TCoreWin32Exception(eErr_WaitingFailed, GetLastError(), L"Waiting failed", LOCATION); } void TWorkerThreadController::StopThread() @@ -135,7 +135,7 @@ if (m_hThread != NULL) { if (::SuspendThread(m_hThread) == (DWORD)-1) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotSuspendThread, GetLastError()); + throw TCoreWin32Exception(eErr_CannotSuspendThread, GetLastError(), L"Failed to suspend thread", LOCATION); if (!::SetThreadPriority(m_hThread, iPriority)) { @@ -146,11 +146,11 @@ dwResult; // to avoid warnings in release builds BOOST_ASSERT(dwResult != (DWORD)-1); - THROW_CORE_EXCEPTION_WIN32(eErr_CannotChangeThreadPriority, dwLastError); + throw TCoreWin32Exception(eErr_CannotChangeThreadPriority, dwLastError, L"Failed to set thread priority", LOCATION); } if (::ResumeThread(m_hThread) == (DWORD)-1) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResumeThread, GetLastError()); + throw TCoreWin32Exception(eErr_CannotResumeThread, GetLastError(), L"Failed to resume thread", LOCATION); } } @@ -179,7 +179,7 @@ if (WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0) { if (!::ResetEvent(m_hKillThread)) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResetEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotResetEvent, GetLastError(), L"Failed to reset event", LOCATION); boost::upgrade_to_unique_lock lock_upgraded(rUpgradeLock); @@ -195,7 +195,7 @@ return; if (!::SetEvent(m_hKillThread)) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotSetEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotSetEvent, GetLastError(), L"Failed to set event", LOCATION); } void TWorkerThreadController::WaitForThreadToExit(boost::upgrade_lock& rUpgradeLock, DWORD dwMiliseconds) @@ -207,14 +207,14 @@ if (dwRes == WAIT_OBJECT_0) { if (!::ResetEvent(m_hKillThread)) - THROW_CORE_EXCEPTION_WIN32(eErr_CannotResetEvent, GetLastError()); + throw TCoreWin32Exception(eErr_CannotResetEvent, GetLastError(), L"Failed to reset event", LOCATION); boost::upgrade_to_unique_lock lock_upgraded(rUpgradeLock); CloseHandle(m_hThread); m_hThread = NULL; } else - THROW_CORE_EXCEPTION_WIN32(eErr_WaitingFailed, GetLastError()); + throw TCoreWin32Exception(eErr_WaitingFailed, GetLastError(), L"Failed to wait for object", LOCATION); } }