Skip to content

Commit 54b480d

Browse files
committed
rework exception handling to always exit
1 parent 7edc134 commit 54b480d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

glrd/update.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def load_releases_from_file(json_file):
7373
return data.get('releases', [])
7474
except Exception as e:
7575
logging.error(f"Error loading releases from {json_file}: {e}")
76-
return []
76+
sys.exit(ERROR_CODES["file_not_found"])
7777

7878
def save_releases(releases, json_file):
7979
"""Save releases to a JSON file."""
@@ -105,7 +105,7 @@ def fetch_s3_bucket_contents(args):
105105

106106
except Exception as e:
107107
logging.error(f"Error fetching S3 bucket contents: {e}")
108-
return []
108+
sys.exit(ERROR_CODES["s3_error"])
109109

110110
def update_flavors(release):
111111
"""Update flavors for a release."""
@@ -176,7 +176,7 @@ def process_releases(args):
176176
logging.info("Successfully downloaded files from S3")
177177
except Exception as e:
178178
logging.error(f"Error downloading files from S3: {e}")
179-
return
179+
sys.exit(ERROR_CODES["s3_error"])
180180

181181
# Get artifacts from artifacts bucket
182182
logging.info(f"Fetching artifacts data from S3 bucket {DEFAULTS['ARTIFACTS_S3_BUCKET_NAME']}")
@@ -271,6 +271,7 @@ def process_releases(args):
271271

272272
except Exception as e:
273273
logging.error(f"Error processing {json_file}: {e}", exc_info=True)
274+
sys.exit(ERROR_CODES["input_error"])
274275

275276
# Upload to S3 if requested and files were modified
276277
if args.s3_update and successful_files:
@@ -280,6 +281,7 @@ def process_releases(args):
280281
logging.info("Successfully uploaded files to S3")
281282
except Exception as e:
282283
logging.error(f"Error uploading files to S3: {e}")
284+
sys.exit(ERROR_CODES["s3_error"])
283285

284286
# Log summary
285287
logging.info("\nUpdate Summary:")

glrd/util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"s3_error": 4,
1616
"query_error": 5,
1717
"parameter_missing": 6,
18+
"invalid_field": 7,
19+
"http_error": 8,
20+
"file_not_found": 9,
21+
"format_error": 10,
22+
"input_error": 11,
1823
}
1924

2025
DEFAULTS = {
@@ -87,7 +92,8 @@ def timestamp_to_isotime(timestamp):
8792
dt = datetime.fromtimestamp(timestamp, pytz.UTC)
8893
return dt.strftime('%H:%M:%S')
8994
except (ValueError, TypeError):
90-
return 'N/A'
95+
logging.error(f"Error converting timestamp to ISO time: {timestamp}")
96+
sys.exit(ERROR_CODES['format_error'])
9197

9298
def isodate_to_timestamp(isodate):
9399
"""

0 commit comments

Comments
 (0)