VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Exception.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-05 18:15:41 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-06 01:19:21 +0200
commit724043be0b9ed68382c49c54b4750ddeaebe81c4 (patch)
treef93ab6d2b1597b9fd2c3c354f0c730b805cc3c57 /src/Common/Exception.h
parentc3b77fba25539c433c882d980169f2c68329e996 (diff)
downloadVeraCrypt-724043be0b9ed68382c49c54b4750ddeaebe81c4.tar.gz
VeraCrypt-724043be0b9ed68382c49c54b4750ddeaebe81c4.zip
Windows: Display source location of errors in order to help diagnose issues reported by users
Diffstat (limited to 'src/Common/Exception.h')
-rw-r--r--src/Common/Exception.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Common/Exception.h b/src/Common/Exception.h
index 0883df14..06545c65 100644
--- a/src/Common/Exception.h
+++ b/src/Common/Exception.h
@@ -11,6 +11,7 @@
#include "Platform/PlatformBase.h"
#include "Dlgcode.h"
+#include "Language.h"
#include <strsafe.h>
namespace VeraCrypt
@@ -22,30 +23,32 @@ namespace VeraCrypt
struct SystemException : public Exception
{
- SystemException () : ErrorCode (GetLastError()) { }
+ SystemException (const char *srcPos) : ErrorCode (GetLastError()), SrcPos (srcPos) { }
void Show (HWND parent) const
{
SetLastError (ErrorCode);
- handleWin32Error (parent);
+ handleWin32Error (parent, SrcPos);
}
DWORD ErrorCode;
+ const char *SrcPos;
};
struct ErrorException : public Exception
{
- ErrorException (char *langId) : ErrLangId (langId) { }
- ErrorException (const wstring &errMsg) : ErrLangId(NULL), ErrMsg (errMsg) { }
+ ErrorException (char *langId, const char *srcPos) : SrcPos (srcPos), ErrLangId (langId) { }
+ ErrorException (const wstring &errMsg, const char *srcPos) : SrcPos (srcPos), ErrLangId(NULL), ErrMsg (errMsg) { }
void Show (HWND parent) const
{
if (ErrMsg.empty())
- ::Error (ErrLangId? ErrLangId : "", parent);
+ ::ErrorDirect (AppendSrcPos (GetString (ErrLangId? ErrLangId : ""), SrcPos).c_str (), parent);
else
- ::ErrorDirect (ErrMsg.c_str(), parent);
+ ::ErrorDirect (AppendSrcPos (ErrMsg.c_str(), SrcPos).c_str (), parent);
}
+ const char *SrcPos;
char *ErrLangId;
wstring ErrMsg;
};
@@ -97,8 +100,10 @@ namespace VeraCrypt
struct TimeOut : public Exception
{
- TimeOut (const char *srcPos) { }
- void Show (HWND parent) const { ErrorDirect (L"Timeout", parent); }
+ TimeOut (const char *srcPos) : SrcPos (srcPos) { }
+ void Show (HWND parent) const { ErrorDirect (AppendSrcPos (L"Timeout", SrcPos).c_str (), parent); }
+
+ const char *SrcPos;
};
struct UserAbort : public Exception
@@ -108,7 +113,7 @@ namespace VeraCrypt
};
}
-#define throw_sys_if(condition) do { if (condition) throw SystemException(); } while (false)
+#define throw_sys_if(condition) do { if (condition) throw SystemException( SRC_POS ); } while (false)
#endif // TC_HEADER_Common_Exception