Skip to content

Commit

Permalink
refactored exception catching to include all possible exceptions #88
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoGuarnaccia5 committed Jun 24, 2024
1 parent 54a4e7b commit 4da1746
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ldap_jwt_auth/core/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_maintenance_state(self) -> MaintenanceState:
with open(config.maintenance.maintenance_path, "r", encoding='utf-8') as file:
data = json.load(file)
return MaintenanceState(**data)
except IOError as exc:
except (OSError, json.JSONDecodeError, TypeError) as exc:
raise MissingMaintenanceFileError("Unable to find maintenance file") from exc
except ValidationError as exc:
raise InvalidMaintenanceFileError("Maintenance file format is incorrect") from exc
Expand All @@ -43,7 +43,7 @@ def get_scheduled_maintenance_state(self) -> ScheduledMaintenanceState:
with open(config.maintenance.scheduled_maintenance_path, "r", encoding='utf-8') as file:
data = json.load(file)
return ScheduledMaintenanceState(**data)
except IOError as exc:
except (OSError, json.JSONDecodeError, TypeError) as exc:
raise MissingMaintenanceFileError("Unable to find scheduled maintenance file") from exc
except ValidationError as exc:
raise InvalidMaintenanceFileError("Scheduled maintenance file format is incorrect") from exc

0 comments on commit 4da1746

Please sign in to comment.