Catch ValueError in API