Skip to content

[BUG] Incorrect exception type when using Boost futures #534

@karzhenkov

Description

@karzhenkov

The following program reports an exception of unknown type when REDIS_PLUS_PLUS_ASYNC_FUTURE is set to boost and there is no running Redis server:

#include <sw/redis++/async_redis++.h>
#include <iostream>

int main() {
  sw::redis::AsyncRedis redis("tcp://127.0.0.1:6379");
  try {
    if (auto value = redis.get("key").get()) {
      std::cout << "value: " << *value << std::endl;
    }
  } catch (const sw::redis::Error& e) {
    std::cerr << "[sw::redis::Error] " << e.what() << '\n';
  } catch (const std::exception& e) {
    std::cerr << "[std::exception] " << e.what() << '\n';
  } catch (...) {
    std::cerr << "[unknown error]\n";
  }
}

The output is as follows:

[unknown error]

Without REDIS_PLUS_PLUS_ASYNC_FUTURE, the output looks as expected:

[sw::redis::Error] failed to connect to Redis (127.0.0.1:6379): Connection refused

Environment:

  • OS: ubuntu
  • Compiler: gcc 13.2.0
  • hiredis version: v1.2.0
  • redis-plus-plus version: master, commit 5eccac2

Additional context
The problem might be related to using std::exception_ptr where boost::exception_ptr is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions