{auto} when wrapping a tagger around a channel that already has an error-callback installed, we should preserve the old callback

This commit is contained in:
Emiel Bruijntjes 2023-02-23 11:06:15 +01:00
parent 84a87d8f93
commit a37c354bea
2 changed files with 12 additions and 1 deletions

View File

@ -207,6 +207,14 @@ public:
// connection is gone
_connection = nullptr;
}
/**
* Expose the currently installed callbacks
* @return ErrorCallback
*/
const ErrorCallback &onError() const { return _errorCallback; }
const SuccessCallback &onReady() const { return _readyCallback; }
/**
* Callback that is called when the channel was succesfully created.

View File

@ -4,7 +4,7 @@
* Implementation for Tagger class.
*
* @author Michael van der Werve <michael.vanderwerve@mailerq.com>
* @copyright 2020 Copernica BV
* @copyright 2020 - 2023 Copernica BV
*/
/**
@ -34,6 +34,9 @@ Tagger::Tagger(Channel &channel) : _implementation(channel._implementation)
// we might have failed, in which case we throw
if (!deferred) throw std::runtime_error("could not enable publisher confirms");
// remember the original callback
_errorCallback = _implementation->onError();
// we wrap a handling error callback that calls our member function
_implementation->onError([this](const char *message) { reportError(message); });
}