예제 #1
0
fluent::Sender::Sender(
                const std::string& h, int p,
                size_t b, float _timeout, bool v)
    :  host(h), port(p), bufmax(b), timeout(_timeout), verbose(v),
        buf(nullptr), sock(Socket::INET, Socket::STREAM)
{
#ifdef FLUENT_MT
    int retval = pthread_mutex_init(&mutex, NULL);
    switch(retval)
    {
        case 0:
            /* success! */
            break;
        case EAGAIN:
            throw NoResources(EAGAIN);
            break;
        case EINVAL:
            throw InvalidAttributes();
            break;
        case ENOMEM:
            throw NoMemory();
            break;
        default:
            throw UnknownError(retval);
    }
#endif
    try {
        reconnect();
    }
    catch(...) {
        close();
    }
}
예제 #2
0
std::exception_ptr BaseFunction::handleError(const FunctionCallResult &result) const
{
    switch (result.status()) {
    case FunctionCallResult::Status::Success:
        break;
    case FunctionCallResult::Status::InvalidArgument:
        return std::make_exception_ptr(
                InvalidArgument("invalid argument to " + _ecmKey));
    case FunctionCallResult::Status::UndefinedReference:
        return std::make_exception_ptr(
                UndefinedReference("undefined reference to " + _ecmKey));
    case FunctionCallResult::Status::NetworkError:
        return std::make_exception_ptr(
                NetworkError("failed to call " + _ecmKey + " due to network error"));
    default:
        return std::make_exception_ptr(
                UnknownError("unknown error when calling " + _ecmKey));
    }
    return nullptr;
}