eclipse / paho.mqtt.cpp

Other
1.01k stars 432 forks source link

add token::get_message #484

Closed Aposhian closed 7 months ago

Aposhian commented 7 months ago

I ran into a situation where I wanted to get the error message from the underlying C library (this is when the failure callback is called for connect).

The workaround I made was doing a const_cast on the token reference passed to the callback, and then calling try_wait, in order to trigger check_ret, which includes the error message in the exception it throws.

It would be nicer if you could just access the message on the token like you can for the reason code and return code.

fpagliughi commented 7 months ago

Good idea. But maybe it should be more explicit? get_error_message() ?

fpagliughi commented 7 months ago

Thanks!