apiv2: fix incorrect exception type in try/except