javacommons/security/javaunicertstoreplugin/tsrc/utils/testfailedexception.h
branchRCL_3
changeset 14 04becd199f91
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javacommons/security/javaunicertstoreplugin/tsrc/utils/testfailedexception.h	Tue Apr 27 16:30:29 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef TESTFAILEDEXCEPTION_H
+#define TESTFAILEDEXCEPTION_H
+
+#include <string>
+#include <exception>
+
+class TestFailedException : public std::exception
+{
+public:
+
+    TestFailedException(const std::string& message, const std::string& file,
+                        const std::string& method, int line);
+
+    virtual ~TestFailedException() throw() {}
+
+    std::string toString() const;
+
+    TestFailedException(const TestFailedException& x)
+    {
+        mErrCode = x.mErrCode;
+        mMessage = x.mMessage;
+        mFile    = x.mFile;
+        mMethod  = x.mMethod;
+        mLine    = x.mLine;
+    }
+
+    int         mErrCode;
+    std::string mMessage;
+    std::string mFile;
+    std::string mMethod;
+    int         mLine;
+
+private:
+    TestFailedException& operator= (const TestFailedException&);
+};
+
+inline TestFailedException::TestFailedException(const std::string& message, const std::string& file,
+        const std::string& method, int line)
+        : mErrCode(0),mMessage(message), mFile(file), mMethod(method),mLine(line) {}
+
+inline std::string TestFailedException::toString() const
+{
+    std::string str;
+    if (0 != mErrCode)
+    {
+        char errCode[7];
+        sprintf(errCode, "%d, ", mErrCode);
+        str.append(errCode);
+    }
+    str.append(mMessage);
+
+    str.append(" (file: ");
+    str.append(mFile);
+
+    str.append(", method: ");
+    str.append(mMethod);
+
+    str.append(", line: ");
+    char line[7];
+    sprintf(line, "%d", mLine);
+    str.append(line);
+    str.append(").");
+    return str;
+}
+
+#endif // TESTFAILEDEXCEPTION_H
+