-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom exceptions for better error handling
- Loading branch information
Showing
4 changed files
with
77 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class DatetimeFailed(Exception): | ||
def __init__(self, model, time): | ||
msg = f"Weather model {model} failed to download for datetime {time}" | ||
super().__init__(msg) | ||
|
||
|
||
class DatetimeNotAvailable(Exception): | ||
def __init__(self, model, time): | ||
msg = f"Weather model {model} was not found for datetime {time}" | ||
super().__init__(msg) | ||
|
||
|
||
class DatetimeOutsideRange(Exception): | ||
def __init__(self, model, time): | ||
msg = f"Time {time} is outside the available date range for weather model {model}" | ||
super().__init__(msg) | ||
|
||
|
||
class ExistingWeatherModelTooSmall(Exception): | ||
def __init__(self): | ||
msg = 'The weather model passed does not cover all of the input ' \ | ||
'points; you may need to download a larger area.' | ||
super().__init__(msg) | ||
|
||
|
||
class TryToKeepGoingError(Exception): | ||
def __init__(self, date=None): | ||
if date is not None: | ||
msg = 'The weather model does not exist for date {date}, so I will try to use the closest available date.' | ||
else: | ||
msg = 'I will try to keep going' | ||
super().__init__(msg) | ||
|
||
|
||
class CriticalError(Exception): | ||
def __init__(self): | ||
msg = 'I have experienced a critical error, please take a look at the log files' | ||
super().__init__(msg) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters