Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show proper error message instead of stacktrace if boefje API is unreachable #3550

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions boefjes/images/oci_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

def main():
input_url = sys.argv[-1]
boefje_input = httpx.get(input_url).json()
try:
boefje_input = httpx.get(input_url).json()
except httpx.HTTPError as e:
# sys.exit will print the message on stderr and return with exit code 1
sys.exit(f"Failed to get input from boefje API: {e}")

try:
os.environ.update(boefje_input["boefje_meta"]["environment"])
Expand All @@ -32,7 +36,10 @@ def main():
],
}

httpx.post(boefje_input["output_url"], json=out)
try:
httpx.post(boefje_input["output_url"], json=out)
except httpx.HTTPError as e:
sys.exit(f"Failed to post output to boefje API: {e}")


if __name__ == "__main__":
Expand Down