Connacht recovered from blowing a 19-0 lead to beat Matt Sherratt’s Cardiff 24-19 in the United Rugby Championship.