getSafeResponseBody method
Extract safe response body
Implementation
String? getSafeResponseBody() {
if (body == null) return null;
// Only capture error responses or small successful responses
const maxBodySize = 512; // 512B limit for responses
if (statusCode >= 400) {
// Capture error responses (truncated)
if (body!.length > maxBodySize) {
return '${body!.substring(0, maxBodySize)}... [truncated]';
}
return body;
}
// For successful responses, only capture small ones
if (body!.length <= 100) {
return body;
}
return '[RESPONSE_TOO_LARGE]';
}