Skip to content

Commit d5469c3

Browse files
committed
Add better error handling to site generation script
- Check for API errors before extracting content - Add logging to show progress - Use jq's empty operator to handle null values
1 parent be5ca7e commit d5469c3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/scripts/generate-site.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,23 @@ jq -n \
1818
> request.json
1919

2020
# Call Claude API
21+
echo "Calling Claude API..."
2122
curl -s https://api.anthropic.com/v1/messages \
2223
-H "content-type: application/json" \
2324
-H "x-api-key: $ANTHROPIC_API_KEY" \
2425
-H "anthropic-version: 2023-06-01" \
2526
-d @request.json > response.json
2627

28+
# Check for API errors
29+
if jq -e '.error' response.json > /dev/null 2>&1; then
30+
echo "API Error:"
31+
jq '.error' response.json
32+
exit 1
33+
fi
34+
2735
# Extract HTML
28-
jq -r '.content[0].text' response.json > docs/index.html.new
36+
echo "Extracting generated HTML..."
37+
jq -r '.content[0].text // empty' response.json > docs/index.html.new
2938

3039
# Verify output
3140
if [ ! -s docs/index.html.new ]; then

0 commit comments

Comments
 (0)