Author: aconway
Date: Fri Apr 4 12:35:14 2008
New Revision: 644845
URL: http://svn.apache.org/viewvc?rev=644845&view=rev
Log:
Minor cleanup of base Exception and python_tests script.
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h
incubator/qpid/trunk/qpid/cpp/src/tests/python_tests
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.cpp?rev=644845&r1=644844&r2=644845&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.cpp Fri Apr 4 12:35:14
2008
@@ -33,31 +33,23 @@
return std::string(strerror_r(err, buf, sizeof(buf)));
}
-Exception::Exception(const std::string& msg,
- const std::string& nm,
- uint16_t cd) throw()
- : message(msg), name(nm), code(cd),
- whatStr((name.empty() ? "" : name + ": ")+ msg)
-{
- QPID_LOG(warning, "Exception: " << whatStr);
+Exception::Exception(const std::string& msg) throw() : message(msg) {
+ QPID_LOG(warning, "Exception: " << message);
}
Exception::~Exception() throw() {}
-std::string Exception::getMessage() const throw() { return message; }
-
-std::string Exception::getName() const throw() {
- return name.empty() ? typeid(*this).name() : name;
-}
-
-uint16_t Exception::getCode() const throw() { return code; }
+std::string Exception::getPrefix() const { return typeid(*this).name(); }
const char* Exception::what() const throw() {
- if (whatStr.empty()) return typeid(*this).name();
- else return whatStr.c_str();
+ if (whatStr.empty())
+ whatStr = getPrefix() + ": " + message;
+ return whatStr.c_str();
}
ClosedException::ClosedException(const std::string& msg)
- : Exception(msg, "ClosedException") {}
+ : Exception(msg) {}
+
+std::string ClosedException::getPrefix() const { return "Closed"; }
} // namespace qpid
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h?rev=644845&r1=644844&r2=644845&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h Fri Apr 4 12:35:14 2008
@@ -40,27 +40,15 @@
class Exception : public std::exception
{
public:
- explicit Exception(const std::string& message=std::string(),
- const std::string& name=std::string(),
- uint16_t code=0) throw();
-
+ explicit Exception(const std::string& message=std::string()) throw();
virtual ~Exception() throw();
-
- // returns "name: message"
virtual const char* what() const throw();
- virtual std::string getName() const throw();
- virtual std::string getMessage() const throw();
- virtual uint16_t getCode() const throw();
-
- // FIXME aconway 2008-02-21: backwards compat, remove?
- std::string str() const throw() { return getMessage(); }
-
+ protected:
+ std::string getPrefix() const;
private:
- const std::string message;
- const std::string name;
- const uint16_t code;
- const std::string whatStr;
+ std::string message;
+ mutable std::string whatStr;
};
/**
@@ -90,6 +78,7 @@
struct ClosedException : public Exception {
ClosedException(const std::string& msg=std::string());
+ std::string getPrefix() const;
};
} // namespace qpid
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/python_tests
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/python_tests?rev=644845&r1=644844&r2=644845&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/python_tests (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/python_tests Fri Apr 4 12:35:14
2008
@@ -1,7 +1,11 @@
#!/bin/sh
# Run the python tests.
+QPID_PORT=${QPID_PORT:-5672}
+PYTHON_TESTS=${PYTHON_TESTS:-$*}
if test -d ../../../python ; then
- cd ../../../python && ./run-tests --skip-self-test -v -s
../specs/amqp.0-10-preview.xml -I cpp_failing_0-10_preview.txt -b
localhost:$QPID_PORT $PYTHON_TESTS && ./run-tests --skip-self-test -v -s "0-10"
-I cpp_failing_0-10.txt -b localhost:$QPID_PORT $PYTHON_TESTS
+ cd ../../../python
+ test -z "$QPID_NO_PREVIEW" && ./run-tests --skip-self-test -v -s
../specs/amqp.0-10-preview.xml -I cpp_failing_0-10_preview.txt -b
localhost:$QPID_PORT $PYTHON_TESTS
+ ./run-tests --skip-self-test -v -s "0-10" -I cpp_failing_0-10.txt -b
localhost:$QPID_PORT $PYTHON_TESTS
else
echo Warning: python tests not found.
fi