[
https://issues.apache.org/jira/browse/GEODE-3624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254456#comment-16254456
]
ASF GitHub Bot commented on GEODE-3624:
---------------------------------------
dgkimura commented on a change in pull request #152: GEODE-3624: Update C++
client exceptions to implement std::exception interface
URL: https://github.com/apache/geode-native/pull/152#discussion_r151284670
##########
File path: cppcache/include/geode/Exception.hpp
##########
@@ -42,87 +44,49 @@ class StackTrace;
* @class Exception Exception.hpp
* A description of an exception that occurred during a cache operation.
*/
-class CPPCACHE_EXPORT Exception {
+class CPPCACHE_EXPORT Exception : public std::exception {
/**
* @brief public methods
*/
public:
/** Creates an exception.
* @param msg1 message pointer, this is copied into the exception.
- * @param msg2 optional extra message pointer, appended to msg1.
- * @param forceTrace enables a stacktrace for this exception regardless of
- * stacktrace-enabled system property.
- * @param cause optional cause of the exception which can be later
- * retrieved using <code>getCause</code>
**/
- Exception(const char* msg1, const char* msg2 = nullptr,
- bool forceTrace = false, const std::shared_ptr<Exception>& cause =
nullptr);
+ Exception(const char* msg1);
- explicit Exception(const std::string& msg1);
+ Exception(const std::string& msg1);
/** Creates an exception as a copy of the given other exception.
* @param other the original exception.
*
**/
- Exception(const Exception& other) noexcept = default;
+ Exception(const Exception& other) = default;
Exception(Exception&& other) noexcept = default;
- /** Create a clone of this exception. */
- virtual Exception* clone() const;
-
/**
* @brief destructor
*/
- virtual ~Exception();
-
- /** Returns the message pointer
- *
- * @return message pointer
- */
- virtual const char* getMessage() const;
- /** Show the message pointer
- *
- */
- virtual void showMessage() const;
-
- /** On some platforms, print a stacktrace from the location the exception
- * was created.
- */
- virtual void printStackTrace() const;
+ virtual ~Exception() noexcept;
-#ifndef _SOLARIS
- /** On some platforms, get a stacktrace string from the location the
- * exception was created.
+ /** Get a stacktrace string from the location the exception was created.
*/
- virtual size_t getStackTrace(char* buffer, size_t maxLength) const;
-#endif
+ virtual std::string getStackTrace() const;
/** Return the name of this exception type. */
virtual const char* getName() const;
- /**
- * Throw polymorphically; this allows storing an exception object
- * pointer and throwing it later.
- */
- virtual void raise() { throw *this; }
-
- inline std::shared_ptr<Exception> getCause() const { return m_cause; }
+ virtual const char *what() const noexcept;
protected:
- /** internal constructor used to clone this exception */
- Exception(const std::shared_ptr<CacheableString>& message,
- const std::shared_ptr<StackTrace>& stack,
- const std::shared_ptr<Exception>& cause);
-
static bool s_exceptionStackTraceEnabled;
Review comment:
Sounds good to me.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Update exceptions to more closely match standard exception interface
> --------------------------------------------------------------------
>
> Key: GEODE-3624
> URL: https://issues.apache.org/jira/browse/GEODE-3624
> Project: Geode
> Issue Type: Improvement
> Components: native client
> Reporter: David Kimura
>
> Native client library should follow standard exception interface for any
> thrown exceptions. This means one less custom interface that a customer or
> developer needs to understand.
> {noformat}
> namespace apache {
> namespace geode {
> namespace client {
> class Exception : public std::exception {...};
> class IllegalArgumentException : public Exception {...};
> class TransactionException : public Exception {...};
> class RollbackException : public TransactionException {...};
> // NO - class IllegalArgumentException : public Exception, public
> std::invalid_argument {...};
> // NO - class IllegalArgumentException : public std::invalid_argument {...};
> // NO - class IllegalArgumentException : public Exception, public
> TransactionException {...};
> }
> }
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)