yangdx
commited on
Commit
·
90429d0
1
Parent(s):
624c41c
Fix linting
Browse files
lightrag_webui/src/api/lightrag.ts
CHANGED
@@ -244,10 +244,10 @@ export const checkHealth = async (): Promise<
|
|
244 |
try {
|
245 |
const response = await axiosInstance.get('/health')
|
246 |
return response.data
|
247 |
-
} catch (
|
248 |
return {
|
249 |
status: 'error',
|
250 |
-
message: errorMessage(
|
251 |
}
|
252 |
}
|
253 |
}
|
@@ -302,7 +302,7 @@ export const queryTextStream = async (
|
|
302 |
let errorBody = 'Unknown error';
|
303 |
try {
|
304 |
errorBody = await response.text(); // Try to get error details from body
|
305 |
-
} catch
|
306 |
throw new Error(`HTTP error ${response.status}: ${response.statusText}\n${errorBody}`);
|
307 |
}
|
308 |
|
@@ -314,7 +314,6 @@ export const queryTextStream = async (
|
|
314 |
const decoder = new TextDecoder();
|
315 |
let buffer = '';
|
316 |
|
317 |
-
// eslint-disable-next-line no-constant-condition
|
318 |
while (true) {
|
319 |
const { done, value } = await reader.read();
|
320 |
if (done) {
|
@@ -338,8 +337,8 @@ export const queryTextStream = async (
|
|
338 |
} else if (parsed.error && onError) {
|
339 |
onError(parsed.error);
|
340 |
}
|
341 |
-
} catch (
|
342 |
-
console.error('Error parsing stream chunk:', line,
|
343 |
if (onError) onError(`Error parsing server response: ${line}`);
|
344 |
}
|
345 |
}
|
@@ -355,8 +354,8 @@ export const queryTextStream = async (
|
|
355 |
} else if (parsed.error && onError) {
|
356 |
onError(parsed.error);
|
357 |
}
|
358 |
-
} catch (
|
359 |
-
console.error('Error parsing final chunk:', buffer,
|
360 |
if (onError) onError(`Error parsing final server response: ${buffer}`);
|
361 |
}
|
362 |
}
|
@@ -368,7 +367,7 @@ export const queryTextStream = async (
|
|
368 |
onError(message);
|
369 |
} else {
|
370 |
// If no specific onError handler, maybe throw or log more prominently
|
371 |
-
console.error(
|
372 |
}
|
373 |
}
|
374 |
};
|
|
|
244 |
try {
|
245 |
const response = await axiosInstance.get('/health')
|
246 |
return response.data
|
247 |
+
} catch (error) {
|
248 |
return {
|
249 |
status: 'error',
|
250 |
+
message: errorMessage(error)
|
251 |
}
|
252 |
}
|
253 |
}
|
|
|
302 |
let errorBody = 'Unknown error';
|
303 |
try {
|
304 |
errorBody = await response.text(); // Try to get error details from body
|
305 |
+
} catch { /* ignore */ }
|
306 |
throw new Error(`HTTP error ${response.status}: ${response.statusText}\n${errorBody}`);
|
307 |
}
|
308 |
|
|
|
314 |
const decoder = new TextDecoder();
|
315 |
let buffer = '';
|
316 |
|
|
|
317 |
while (true) {
|
318 |
const { done, value } = await reader.read();
|
319 |
if (done) {
|
|
|
337 |
} else if (parsed.error && onError) {
|
338 |
onError(parsed.error);
|
339 |
}
|
340 |
+
} catch (error) {
|
341 |
+
console.error('Error parsing stream chunk:', line, error);
|
342 |
if (onError) onError(`Error parsing server response: ${line}`);
|
343 |
}
|
344 |
}
|
|
|
354 |
} else if (parsed.error && onError) {
|
355 |
onError(parsed.error);
|
356 |
}
|
357 |
+
} catch (error) {
|
358 |
+
console.error('Error parsing final chunk:', buffer, error);
|
359 |
if (onError) onError(`Error parsing final server response: ${buffer}`);
|
360 |
}
|
361 |
}
|
|
|
367 |
onError(message);
|
368 |
} else {
|
369 |
// If no specific onError handler, maybe throw or log more prominently
|
370 |
+
console.error('Unhandled stream error:', message);
|
371 |
}
|
372 |
}
|
373 |
};
|