Skip to content

Commit

Permalink
Merge pull request #648 from gulfofmaine/error-levels-and-context
Browse files Browse the repository at this point in the history
Add more error context and adjust levels
  • Loading branch information
abkfenris authored Dec 20, 2022
2 parents 70374cd + 70b43c1 commit 237c12c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changes:

Fixes:

- Add error context and adjust levels.

## 0.4.9 - 12/20/2022

Fixes:
Expand Down
29 changes: 23 additions & 6 deletions app/deployments/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def update_values_for_timeseries(timeseries):
return

except OSError as error:
logger.info(
logger.error(
(
f"Error loading dataset {timeseries[0].dataset.name} with "
f"constraints {timeseries[0].constraints}: {error}"
Expand All @@ -73,11 +73,15 @@ def update_values_for_timeseries(timeseries):
try:
row = filtered_df.iloc[-1]
except IndexError:
message = (
logger.error(
f"Unable to find position in dataframe for {series.platform.name} - "
f"{series.variable}"
f"{series.variable}",
extra={
"timeseries": timeseries,
"constraints": timeseries[0].constraints,
},
exc_info=True,
)
logger.error(message)
return

try:
Expand All @@ -97,6 +101,10 @@ def update_values_for_timeseries(timeseries):
except TypeError as error:
logger.error(
f"Could not save {series.variable} from {row}: {error}",
extra={
"timeseries": timeseries,
"constraints": timeseries[0].constraints,
},
exc_info=True,
)

Expand Down Expand Up @@ -169,12 +177,14 @@ def handle_500_variable_actual_range_error(timeseries_group, compare_text: str)
"Your query produced no matching results" in compare_text
and "is outside of the variable's actual_range" in compare_text
):
logger.info(
logger.error(
(
f"{timeseries_group[0].dataset.name} "
f"with constraints {timeseries_group[0].constraints} had a "
"constraint outside of normal range"
),
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand Down Expand Up @@ -267,6 +277,7 @@ def handle_500_unrecognized_constraint(timeseries_group, compare_text: str) -> b
f"with constraints {timeseries_group[0].constraints}"
),
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand Down Expand Up @@ -310,6 +321,7 @@ def handle_429_too_many_requests(timeseries_group, compare_text: str) -> bool:
logger.error(
f"Too many requests to server {timeseries_group[0].dataset.server}",
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand All @@ -322,6 +334,7 @@ def handle_400_unrecognized_variable(timeseries_group, compare_text: str) -> boo
logger.error(
f"Unrecognized variable for dataset {timeseries_group[0].dataset.name}",
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True
return False
Expand Down Expand Up @@ -350,6 +363,7 @@ def handle_404_dataset_file_not_found(timeseries_group, compare_text: str) -> bo
logger.error(
f"{timeseries_group[0].dataset.name} does not exist on the server",
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand All @@ -362,6 +376,7 @@ def handle_404_no_matching_time(timeseries_group, compare_text: str) -> bool:
logger.error(
f"{timeseries_group[0].dataset.name} does not currently have a valid time",
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand All @@ -380,6 +395,7 @@ def handle_404_no_matching_station(timeseries_group, compare_text: str) -> bool:
"Please check the constraints"
),
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand All @@ -398,6 +414,7 @@ def handle_404_no_matching_dataset_id(timeseries_group, compare_text: str) -> bo
"Please investigate if the dataset has moved"
),
extra=error_extra(timeseries_group, compare_text),
exc_info=True,
)
return True

Expand Down Expand Up @@ -440,7 +457,7 @@ def handle_http_errors(timeseries_group, error: HTTPError) -> bool:
if handle_500_errors(timeseries_group, response_500.text):
return True

logger.info(
logger.error(
(
f"500 error loading dataset {timeseries_group[0].dataset.name} "
f"with constraint {timeseries_group[0].constraints}: {error} "
Expand Down

0 comments on commit 237c12c

Please sign in to comment.