diff options
author | Tobias Markmann <tm@ayena.de> | 2017-03-13 08:43:28 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-03-13 09:07:42 (GMT) |
commit | 9601c3e0475a4d05c4c245183c787bd7de805be6 (patch) | |
tree | 1e9aa5e23a6c517eb8b0f5cdb139808af5afb499 | |
parent | a7ea0a4f7899ce7365cdc293089641ac2b39dfb8 (diff) | |
download | swift-9601c3e0475a4d05c4c245183c787bd7de805be6.zip swift-9601c3e0475a4d05c4c245183c787bd7de805be6.tar.bz2 |
Add LogSerializer for BOSHError
Test-Information:
Tested and used it during a recent debugging session on
macOS 10.12.3 with recent clang.
Change-Id: Ia4883a69a94f962006a39b294d6b9b67e0990541
-rw-r--r-- | Swiften/Base/LogSerializers.cpp | 54 | ||||
-rw-r--r-- | Swiften/Base/LogSerializers.h | 5 | ||||
-rw-r--r-- | Swiften/Network/BOSHConnection.h | 4 |
3 files changed, 59 insertions, 4 deletions
diff --git a/Swiften/Base/LogSerializers.cpp b/Swiften/Base/LogSerializers.cpp index 5ac1e15..3f8e9ce 100644 --- a/Swiften/Base/LogSerializers.cpp +++ b/Swiften/Base/LogSerializers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -7,6 +7,7 @@ #include <Swiften/Base/LogSerializers.h> #include <Swiften/Elements/Presence.h> +#include <Swiften/Network/BOSHConnection.h> namespace Swift { @@ -65,6 +66,57 @@ std::ostream& operator<<(std::ostream& stream, const Presence& presence) { return stream; } +std::ostream& operator<<(std::ostream& stream, const BOSHError& boshError) { + std::string errorString; + switch (boshError.getType()) { + case BOSHError::BadRequest: + errorString = "BadRequest"; + break; + case BOSHError::HostGone: + errorString = "HostGone"; + break; + case BOSHError::HostUnknown: + errorString = "HostUnknown"; + break; + case BOSHError::ImproperAddressing: + errorString = "ImproperAddressing"; + break; + case BOSHError::InternalServerError: + errorString = "InternalServerError"; + break; + case BOSHError::ItemNotFound: + errorString = "ItemNotFound"; + break; + case BOSHError::OtherRequest: + errorString = "OtherRequest"; + break; + case BOSHError::PolicyViolation: + errorString = "PolicyViolation"; + break; + case BOSHError::RemoteConnectionFailed: + errorString = "RemoteConnectionFailed"; + break; + case BOSHError::RemoteStreamError: + errorString = "RemoteStreamError"; + break; + case BOSHError::SeeOtherURI: + errorString = "SeeOtherURI"; + break; + case BOSHError::SystemShutdown: + errorString = "SystemShutdown"; + break; + case BOSHError::UndefinedCondition: + errorString = "UndefinedCondition"; + break; + case BOSHError::NoError: + errorString = "NoError"; + break; + } + + stream << "BOSHError( " << errorString << " )"; + return stream; +} + }; ::std::ostream& operator<<(::std::ostream& os, const boost::optional<std::string>& optStr) { diff --git a/Swiften/Base/LogSerializers.h b/Swiften/Base/LogSerializers.h index be992bb..b804808 100644 --- a/Swiften/Base/LogSerializers.h +++ b/Swiften/Base/LogSerializers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -16,6 +16,7 @@ namespace Swift { class Presence; +class BOSHError; template <typename T> std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<T>& ptr) { @@ -46,6 +47,8 @@ std::ostream& operator<<(std::ostream& stream, const std::vector<T>& vec) { std::ostream& operator<<(std::ostream& stream, const Presence& presence); +std::ostream& operator<<(std::ostream& stream, const BOSHError& boshError); + }; ::std::ostream& operator<<(::std::ostream& os, const boost::optional<std::string>& optStr); diff --git a/Swiften/Network/BOSHConnection.h b/Swiften/Network/BOSHConnection.h index b75e51f..1409ae6 100644 --- a/Swiften/Network/BOSHConnection.h +++ b/Swiften/Network/BOSHConnection.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -50,7 +50,7 @@ namespace Swift { NoError}; BOSHError(Type type) : SessionStream::SessionStreamError(SessionStream::SessionStreamError::ConnectionReadError), type(type) {} - Type getType() {return type;} + Type getType() const {return type;} typedef std::shared_ptr<BOSHError> ref; private: |