I am fairly new to python and need recommendations on how to handle internal/helper function failures.
I have a script that that imports a list of jurisdictions, then iterates through that list and creates a view, map, and experience builder application tailored to that jurisdiction. It's working more or less flawlessly but is routinely failing on the third iteration. And the failure happens due to an error with the arcgis\features\managers.py helper.
KeyError Traceback (most recent call last)
c:\Users\user\path_to_project\script.py in <cell line: 40>()
224 for j in jList: #changed 'jurisdiction' to 'j'
225 #*Create Views
---> 226 jView = masterLayer.manager.create_view(name = j + '_view', spatial_reference = sr, tags = tagsText, capabilities = "Create,Query,Update,Delete,Editing,ChangeTracking")
227 jView.move(folder = folder)
228 jViewFLC = arcgis.features.FeatureLayerCollection.fromitem(jView)
c:\Users\user\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\managers.py in create_view(self, name, spatial_reference, extent, allow_schema_changes, updateable, capabilities, view_layers, view_tables, description, tags, snippet, overwrite, set_item_id, preserve_layer_ids)
2006 params["description"] = description
2007 res = gis._con.post(path=url, postdata=params)
-> 2008 view = content.get(res["itemId"])
2009 fs_view = FeatureLayerCollection(url=view.url, gis=gis)
2010 add_def = {"layers": [], "tables": []}
KeyError: 'itemId'
The loop runs all the way through the first two items in the list and then fails routinely on the third. It was running all the way through two days ago and nothing has changed with this aspect of the script.
How do I isolate the error when it happens within the package?