@ai-matrx/agents 0.38.2 → 0.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1088,26 +1088,27 @@ function isStreamTransportLost(error) {
1088
1088
  }
1089
1089
  async function parseHttpError(response) {
1090
1090
  const status = response.status;
1091
- let body = null;
1091
+ let text;
1092
1092
  try {
1093
- body = await response.json();
1093
+ text = await response.text();
1094
1094
  } catch {
1095
- try {
1096
- const text = await response.text();
1097
- return new BackendApiError({
1098
- code: statusToCode(status),
1099
- detail: text || `HTTP ${status}`,
1100
- userMessage: text || `Request failed (${status})`,
1101
- status
1102
- });
1103
- } catch {
1104
- return new BackendApiError({
1105
- code: statusToCode(status),
1106
- detail: `HTTP ${status}`,
1107
- userMessage: `Request failed (${status})`,
1108
- status
1109
- });
1110
- }
1095
+ return new BackendApiError({
1096
+ code: statusToCode(status),
1097
+ detail: `HTTP ${status}`,
1098
+ userMessage: `Request failed (${status})`,
1099
+ status
1100
+ });
1101
+ }
1102
+ let body;
1103
+ try {
1104
+ body = JSON.parse(text);
1105
+ } catch {
1106
+ return new BackendApiError({
1107
+ code: statusToCode(status),
1108
+ detail: text || `HTTP ${status}`,
1109
+ userMessage: text || `Request failed (${status})`,
1110
+ status
1111
+ });
1111
1112
  }
1112
1113
  return parseHttpErrorBody(body, status);
1113
1114
  }