I'm looking for some assistance in error trapping. I have 650 watersheds that I need to calculate the Longest Flow Path for. I have incorporated the tool into a much larger model and currently its failing at Longest Flow Path. I would like to be able run the current tools and for any exception thrown by the tool print the name of the current watershed being processed and continue with the rest. At least then I can go back to see the watersheds that have thrown an exception to see why. Currently I have to manually look for which watershed is causing the error and rerun the tool from scratch.import arcpy, ArcHydroTools
watshed = r'E:\Projects\H109355_2\ArcHydro\Model3\Nigeria03.gdb\Layers\Watershed'
fdr = r'E:\Projects\H109355_2\Archydro\GRID\layers.gdb\Fdr'
ArcHydroTools.LongestFlowpath(watshed,fdr,r'E:\Projects\H109355_2\ArcHyro\Model3\Nigeria03.gdb\Layers\LongestFlowPath')
I've tried the following approach, but overwriteoutput isn't working:import arcpy, ArcHydroTools
outpath = arcpy.env.workspace = r'E:\Projects\H109355_2\ArcHydro\Model3\Nigeria03.gdb\Layers'
arcpy.env.overwriteOutput = True
fdr = r'E:\Projects\H109355_2\ArcHydro\GRID\Layers.gdb\Fdr'
watshed = "Watershed"
with arcpy.da.SearchCursor(watshed,("Name",)) as scur:
for row in scur:
cuindex = row[0]
sqlexp = """{0} = '{1}'""".format(arcpy.AddFieldDelimiters(watshed,"Name"),cuindex)
watshedind = arcpy.FeatureClassToFeatureClass_conversion(watshed,outpath,"watshed",sqlexp)
try:
longflowpath1 = ArcHydroTools.LongestFlowPath(watshedind,fdr,"in_memory\longestflowpath")
except:
arcpy.AddMessage
print cuindex
Any help will be appreciated.Regards