mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 23:25:43 -03:00
feat(api): enhance fetchModelDescription to improve error handling and response parsing
This commit is contained in:
@@ -1011,14 +1011,22 @@ export class BaseModelApiClient {
|
|||||||
|
|
||||||
async fetchModelDescription(filePath) {
|
async fetchModelDescription(filePath) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${this.apiConfig.endpoints.modelDescription}?file_path=${encodeURIComponent(filePath)}`);
|
const params = new URLSearchParams({ file_path: filePath });
|
||||||
|
const response = await fetch(`${this.apiConfig.endpoints.modelDescription}?${params}`);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`Failed to fetch ${this.apiConfig.config.singularName} description: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
|
||||||
|
if (data.success) {
|
||||||
|
return data.description;
|
||||||
|
} else {
|
||||||
|
throw new Error(data.error || `No description found for ${this.apiConfig.config.singularName}`);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching model description:', error);
|
console.error(`Error fetching ${this.apiConfig.config.singularName} description:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user