You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/04/13 16:07:16 UTC
[13/15] ignite git commit: IGNITE-2920: CPP: IgniteError now derives
from std::runtime_error. This closes #589.
IGNITE-2920: CPP: IgniteError now derives from std::runtime_error. This closes #589.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/277678e5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/277678e5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/277678e5
Branch: refs/heads/ignite-1786
Commit: 277678e525c0d4cd702bc8bb8c8df7a8b2cdbfa5
Parents: d9f4f6e
Author: isapego <is...@gridgain.com>
Authored: Wed Apr 13 14:12:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Apr 13 14:12:48 2016 +0300
----------------------------------------------------------------------
.../os/linux/include/ignite/common/common.h | 20 ++++++++++-----
.../os/win/include/ignite/common/common.h | 8 +++++-
.../cpp/core-test/src/ignite_error_test.cpp | 2 +-
.../cpp/core/include/ignite/ignite_error.h | 9 ++++---
modules/platforms/cpp/core/src/ignite_error.cpp | 27 ++++++++++++--------
5 files changed, 42 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/277678e5/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h b/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
index 6577ad8..0ec8e16 100644
--- a/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
+++ b/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
@@ -19,23 +19,29 @@
#define _IGNITE_COMMON_OS
#ifndef __has_attribute
- #define __has_attribute(x) 0
+# define __has_attribute(x) 0
#endif
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
- #define IGNITE_EXPORT __attribute__((visibility("default")))
- #define IGNITE_IMPORT __attribute__((visibility("default")))
+# define IGNITE_EXPORT __attribute__((visibility("default")))
+# define IGNITE_IMPORT __attribute__((visibility("default")))
#else
- #define IGNITE_EXPORT
- #define IGNITE_IMPORT
+# define IGNITE_EXPORT
+# define IGNITE_IMPORT
#endif
#define IGNITE_CALL
#ifdef IGNITE_IMPL
- #define IGNITE_IMPORT_EXPORT IGNITE_EXPORT
+# define IGNITE_IMPORT_EXPORT IGNITE_EXPORT
#else
- #define IGNITE_IMPORT_EXPORT IGNITE_IMPORT
+# define IGNITE_IMPORT_EXPORT IGNITE_IMPORT
+#endif
+
+#if (__cplusplus >= 201103L)
+# define IGNITE_NO_THROW noexcept
+#else
+# define IGNITE_NO_THROW throw()
#endif
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/277678e5/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/include/ignite/common/common.h b/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
index 9e57bde..cf924c8 100644
--- a/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
+++ b/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
@@ -33,7 +33,13 @@
*/
#define IGNITE_NO_COPY_ASSIGNMENT(cls) \
cls(const cls& src); \
- cls& operator= (const cls& other);
+ cls& operator= (const cls& other);
+
+#if (__cplusplus >= 201103L)
+# define IGNITE_NO_THROW noexcept
+#else
+# define IGNITE_NO_THROW throw()
+#endif
namespace ignite
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/277678e5/modules/platforms/cpp/core-test/src/ignite_error_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/ignite_error_test.cpp b/modules/platforms/cpp/core-test/src/ignite_error_test.cpp
index c9e3043..8e379e3 100644
--- a/modules/platforms/cpp/core-test/src/ignite_error_test.cpp
+++ b/modules/platforms/cpp/core-test/src/ignite_error_test.cpp
@@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE(IgniteErrorTestSuite)
BOOST_AUTO_TEST_CASE(TestIgniteErrorDerivesStdException)
{
- const std::string testMsg = "Lorem ipsum dolor sit amet";
+ const std::string testMsg = "Exception was not caught as it was supposed to.";
try
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/277678e5/modules/platforms/cpp/core/include/ignite/ignite_error.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite_error.h b/modules/platforms/cpp/core/include/ignite/ignite_error.h
index 4097a62..4a0e281 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite_error.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite_error.h
@@ -244,14 +244,15 @@ namespace ignite
*
* @return Error message.
*/
- const char* GetText() const;
+ const char* GetText() const IGNITE_NO_THROW;
/**
- * Get error message. Synonim for GetText().
+ * Implementation of the standard std::exception::what() method.
+ * Synonym for GetText() method.
*
- * @return Error message.
+ * @return Error message string.
*/
- virtual const char* what() const;
+ virtual const char* what() const IGNITE_NO_THROW;
/**
* Set error.
http://git-wip-us.apache.org/repos/asf/ignite/blob/277678e5/modules/platforms/cpp/core/src/ignite_error.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/ignite_error.cpp b/modules/platforms/cpp/core/src/ignite_error.cpp
index ad30e46..9963aa5 100644
--- a/modules/platforms/cpp/core/src/ignite_error.cpp
+++ b/modules/platforms/cpp/core/src/ignite_error.cpp
@@ -30,26 +30,31 @@ namespace ignite
throw err;
}
- IgniteError::IgniteError() : code(IGNITE_SUCCESS), msg(NULL)
+ IgniteError::IgniteError() :
+ code(IGNITE_SUCCESS),
+ msg(NULL)
{
// No-op.
}
- IgniteError::IgniteError(int32_t code) : code(code), msg(NULL)
+ IgniteError::IgniteError(int32_t code) :
+ code(code),
+ msg(NULL)
{
- // No-op.
}
- IgniteError::IgniteError(int32_t code, const char* msg)
+ IgniteError::IgniteError(int32_t code, const char* msg) :
+ code(code),
+ msg(CopyChars(msg))
{
- this->code = code;
- this->msg = CopyChars(msg);
+ // No-op.
}
- IgniteError::IgniteError(const IgniteError& other)
+ IgniteError::IgniteError(const IgniteError& other) :
+ code(other.code),
+ msg(CopyChars(other.msg))
{
- this->code = other.code;
- this->msg = CopyChars(other.msg);
+ // No-op.
}
IgniteError& IgniteError::operator=(const IgniteError& other)
@@ -81,7 +86,7 @@ namespace ignite
return code;
}
- const char* IgniteError::GetText() const
+ const char* IgniteError::GetText() const IGNITE_NO_THROW
{
if (code == IGNITE_SUCCESS)
return "Operation completed successfully.";
@@ -91,7 +96,7 @@ namespace ignite
return "No additional information available.";
}
- const char* IgniteError::what() const
+ const char* IgniteError::what() const IGNITE_NO_THROW
{
return GetText();
}