Function: parseHttpErrorResponse()
Gala Launchpad SDK 9.0.0-rc.5 / index / parseHttpErrorResponse
Function: parseHttpErrorResponse()
parseHttpErrorResponse(
error):ParsedHttpError
Defined in: packages/launchpad-sdk/dist/utils/api-patterns.d.ts:286
Parse HTTP error response into standardized structure
Consistently extracts error details from various HTTP error formats:
- Axios errors with response data
- Fetch errors
- Custom error objects with status codes
- Plain text error responses
- JSON error responses
Parameters
error
unknown
Unknown error object from HTTP request
Returns
ParsedHttpError with statusCode, errorMessage, errorData, and raw error
Examples
Axios error
try {
await axios.get('/api/data');
} catch (error) {
const parsed = parseHttpErrorResponse(error);
console.log(`Status: ${parsed.statusCode}, Message: ${parsed.errorMessage}`);
// Status: 404, Message: Not Found
}
Fetch error
try {
const response = await fetch('/api/data');
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
} catch (error) {
const parsed = parseHttpErrorResponse(error);
// Extracts status code and error message
}
Error response with JSON body
try {
await api.post('/endpoint', data);
} catch (error) {
const parsed = parseHttpErrorResponse(error);
console.log(`Error: ${parsed.errorData?.errorCode || parsed.statusCode}`);
}
Since
6.5.0 @adoption_gap Error response parsing appears in 7+ locations with inconsistent patterns