int32_t hr_from_error_code()

in Source/Windows/arcana/hresult.cpp [145:168]


    int32_t hr_from_error_code(const std::error_code& error_code)
    {
        // Make sure we're being asked to convert an actual error.
        assert(static_cast<bool>(error_code));

        if (error_code.category() == hresult_category())
        {
            // already an hresult - no need to modify
            return error_code.value();
        }

        assert((error_code.value() == HRESULT_CODE(error_code.value())) && "error_code value using more than 16 bits, which is too large for an hresult");

        std::optional<int> facility = s_categoryStorage.get_facility(error_code.category());
        if (facility)
        {
            return make_hresult_code(facility.value(), error_code.value());
        }
        else
        {
            assert(false && "Unexpected error category");
            return arcana::underlying_cast(hresult::e_fail);
        }
    }