From 9601c3e0475a4d05c4c245183c787bd7de805be6 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Mon, 13 Mar 2017 09:43:28 +0100 Subject: 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 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 #include +#include 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& 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 std::ostream& operator<<(std::ostream& stream, const std::shared_ptr& ptr) { @@ -46,6 +47,8 @@ std::ostream& operator<<(std::ostream& stream, const std::vector& 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& 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 ref; private: -- cgit v0.10.2-6-g49f6