Skip to content

Commit 6490ce4

Browse files
committed
Combine except statements into single statement
1 parent d4a362a commit 6490ce4

3 files changed

Lines changed: 6 additions & 32 deletions

File tree

download_and_extract_layer_from_agol.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
# Created: 7/9/2020
1515
#
16-
# Updated: 12/14/2021
16+
# Updated: 12/23/2021
1717
# -------------------------------------------------------------------------------
1818

1919
# import modules
@@ -123,16 +123,7 @@
123123
# add message
124124
log_message += '\nCopied data from "{}" to "{}"\n'.format(in_gdb, out_gdb)
125125
# If an error occurs running geoprocessing tool(s) capture error and write message
126-
# handle error outside of Python system
127-
except EnvironmentError as e:
128-
tbE = sys.exc_info()[2]
129-
# add the line number the error occured to the log message
130-
log_message += "\nFailed at Line {}\n".format(tbE.tb_lineno)
131-
# add the error message to the log message
132-
log_message += "\nError: {}\n".format(e)
133-
# handle exception error
134-
except Exception as e:
135-
# Store information about the error
126+
except (Exception, EnvironmentError) as e:
136127
tbE = sys.exc_info()[2]
137128
# add the line number the error occured to the log message
138129
log_message += "\nFailed at Line {}\n".format(tbE.tb_lineno)

overwrite_service_to_agol.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# Created: 9/11/2020
1818
#
19-
# Updated: 12/14/2021
19+
# Updated: 12/23/2021
2020
#
2121
# Author: Patrick McKinney
2222
# --------------------------------------------------------------------------------------------------------------------------------------------
@@ -142,21 +142,12 @@
142142
log_message += "\nOverwrote 'Some Dataset' feature service to ArcGIS Online in {}-minutes on {}\n".format(
143143
elapsed_time_minutes, formatted_date_today)
144144
# If an error occurs running geoprocessing tool(s) capture error and write message
145-
# handle error outside of Python system
146-
except EnvironmentError as e:
145+
except (Exception, EnvironmentError) as e:
147146
tbE = sys.exc_info()[2]
148147
# Write the line number the error occured to the log file
149148
log_message += "\nFailed at Line {}\n".format(tbE.tb_lineno)
150149
# Write the error message to the log file
151150
log_message += "Error: {}".format(str(e))
152-
# handle exception error
153-
except Exception as e:
154-
# Store information about the error
155-
tbE = sys.exc_info()[2]
156-
# Write the line number the error occured to the log file
157-
log_message += "\nFailed at Line {}\n".format(tbE.tb_lineno)
158-
# Write the error message to the log file
159-
log_message += "Error: {}".format(e)
160151
finally:
161152
# write message to log file
162153
try:

rebuild_map_service_tiles_in_updated_areas.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Created: 9/2/2020
99
#
10-
# Updated: 12/14/2021
10+
# Updated: 12/23/2021
1111
# -------------------------------------------------------------------------------------------------------------------
1212

1313
# Import system modules
@@ -143,20 +143,12 @@
143143
service_name, elapsed_time_hours, formatted_date_today)
144144
# If an error occurs running geoprocessing tool(s) capture error and write message
145145
# handle error outside of Python system
146-
except EnvironmentError as e:
146+
except (Exception, EnvironmentError) as e:
147147
tbE = sys.exc_info()[2]
148148
# Write the line number the error occured to the log file
149149
log_message += '\nFailed at Line {}\n'.format(tbE.tb_lineno)
150150
# Write the error message to the log file
151151
log_message += 'Error: {}'.format(str(e))
152-
# handle exception error
153-
except Exception as e:
154-
# Store information about the error
155-
tbE = sys.exc_info()[2]
156-
# Write the line number the error occured to the log file
157-
log_message += '\nFailed at Line {}\n'.format(tbE.tb_lineno)
158-
# Write the error message to the log file
159-
log_message += 'Error: {}'.format(e)
160152
finally:
161153
# write message to log file
162154
try:

0 commit comments

Comments
 (0)