diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-09-04 01:36:28 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-09-04 01:36:28 +0000 |
commit | 812e01faaa17a675a1f473969211fec33c95d4b9 (patch) | |
tree | 563d53906ed0724d7f21c009b4101360d78b4b44 /lib | |
parent | 205525eef4c2c904b4ca1a19f98e8b6b5002404d (diff) |
Refactor FileStream exception throwing.
Avoid duplicate reporting, and include a message in the exceptions thrown.
Merged back changes from the test refactor branch to reduce diffs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/FileStream.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/common/FileStream.cpp b/lib/common/FileStream.cpp index 99b66666..e38e5d38 100644 --- a/lib/common/FileStream.cpp +++ b/lib/common/FileStream.cpp @@ -67,24 +67,29 @@ void FileStream::AfterOpen() { MEMLEAKFINDER_NOT_A_LEAK(this); - #ifdef WIN32 - BOX_LOG_WIN_WARNING_NUMBER("Failed to open file: " << - mFileName, winerrno); - #else - BOX_LOG_SYS_WARNING("Failed to open file: " << - mFileName); - #endif - +#ifdef WIN32 + if(errno == EACCES) + { + THROW_WIN_FILE_ERROR("Failed to open file", mFileName, + CommonException, AccessDenied); + } + else + { + THROW_WIN_FILE_ERROR("Failed to open file", mFileName, + CommonException, OSFileOpenError); + } +#else if(errno == EACCES) { - THROW_EXCEPTION_MESSAGE(CommonException, AccessDenied, - mFileName); + THROW_SYS_FILE_ERROR("Failed to open file", mFileName, + CommonException, AccessDenied); } else { - THROW_EXCEPTION_MESSAGE(CommonException, OSFileOpenError, - mFileName); + THROW_SYS_FILE_ERROR("Failed to open file", mFileName, + CommonException, OSFileOpenError); } +#endif } } |