{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:
parent
84a87d8f93
commit
a37c354bea
|
|
@ -208,6 +208,14 @@ public:
|
||||||
_connection = nullptr;
|
_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.
|
* Callback that is called when the channel was succesfully created.
|
||||||
* @param callback the callback to execute
|
* @param callback the callback to execute
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* Implementation for Tagger class.
|
* Implementation for Tagger class.
|
||||||
*
|
*
|
||||||
* @author Michael van der Werve <michael.vanderwerve@mailerq.com>
|
* @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
|
// we might have failed, in which case we throw
|
||||||
if (!deferred) throw std::runtime_error("could not enable publisher confirms");
|
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
|
// we wrap a handling error callback that calls our member function
|
||||||
_implementation->onError([this](const char *message) { reportError(message); });
|
_implementation->onError([this](const char *message) { reportError(message); });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue