Skip to content

Commit

Permalink
Fix access denied error
Browse files Browse the repository at this point in the history
  • Loading branch information
chelnak committed Dec 2, 2022
1 parent 7f34d8d commit 75a96bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 12 additions & 8 deletions status_cake_exporter/_status_cake.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,19 @@ def list_maintenance_windows(self) -> list[dict[str, Any]]:
return response

except ForbiddenException as e:
message = json.loads(e.body)["message"]
if "Your current plan has no access to this feature" in message:
logger.warn(
(
"Your current plan has no access to this feature or your account is "
"using legacy maintenance windows. Skipping maintenance window check."
if e.body:
message = json.loads(e.body)["message"]
if (
message
and "Your current plan has no access to this feature" in message
):
logger.warn(
(
"Your current plan has no access to this feature or your account is "
"using legacy maintenance windows. Skipping maintenance window check."
)
)
)
return []
return []

# re-raise here because it might be genuine.
raise e
Expand Down
3 changes: 3 additions & 0 deletions status_cake_exporter/_test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ def collect(self):
yield uptime_gauge

except Exception as e:
import traceback

# This should stop the expoter from crashing if there is an error.
logger.fatal(f"A fatal error occurred: {e}")
logger.debug(traceback.format_exc())

finally:
logger.info("Collector finished.")

0 comments on commit 75a96bf

Please sign in to comment.