You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: extract clean error messages from API responses (#64)
* fix: extract clean error messages from API responses
When API requests fail with non-JSON responses (like HTML error pages),
error messages now show the HTTP status code (e.g., "HTTP 521 Web Server
Is Down") instead of serializing the entire response body.
Added getApiErrorMessage(error, response) utility that extracts clean
error messages from ODS, OCAPI, and SCAPI error patterns with HTTP
status fallback.
* docs: update skills with getApiErrorMessage pattern
Update CLI command development and API client development skills to
document the new getApiErrorMessage utility for handling API errors
cleanly.
Fix HTML response bodies appearing in ERROR log lines. When API requests fail with non-JSON responses (like HTML error pages), error messages now show the HTTP status code (e.g., "HTTP 521 Web Server Is Down") instead of serializing the entire response body.
7
+
8
+
Added `getApiErrorMessage(error, response)` utility that extracts clean error messages from ODS, OCAPI, and SCAPI error patterns with HTTP status fallback.
When API requests fail, use `getApiErrorMessage()` to extract clean, user-friendly error messages. This utility handles multiple error formats and ensures HTML response bodies (like error pages from stopped sandboxes) are never shown to users.
**Important:** Always destructure `response` alongside `error` when making API calls. The `getApiErrorMessage` utility extracts clean messages from ODS, OCAPI, and SCAPI error patterns, and falls back to HTTP status (e.g., "HTTP 521 Web Server Is Down") for non-JSON responses like HTML error pages.
321
+
322
+
See [API Client Development](../api-client-development/SKILL.md#error-handling) for supported error patterns.
323
+
316
324
## Creating a Command Checklist
317
325
318
326
1. Create file at `packages/b2c-cli/src/commands/<topic>/<command>.ts`
0 commit comments