mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-24 14:02:11 -03:00
Improve matting error handling and user feedback
Adds checks for missing 'transformers' dependency and network errors in the matting endpoint, returning clear error messages for common failure cases. Updates the frontend to display more informative alerts to users when matting fails, including details from server responses.
This commit is contained in:
@@ -826,9 +826,15 @@ async function createCanvasWidget(node, widget, app) {
|
||||
body: JSON.stringify({image: imageData})
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error(`Server error: ${response.status} - ${response.statusText}`);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
let errorMsg = `Server error: ${response.status} - ${response.statusText}`;
|
||||
if (result && result.error) {
|
||||
errorMsg = `Error: ${result.error}\n\nDetails: ${result.details}`;
|
||||
}
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const mattedImage = new Image();
|
||||
mattedImage.src = result.matted_image;
|
||||
await mattedImage.decode();
|
||||
@@ -840,7 +846,7 @@ async function createCanvasWidget(node, widget, app) {
|
||||
canvas.saveState();
|
||||
} catch (error) {
|
||||
log.error("Matting error:", error);
|
||||
alert(`Error during matting process: ${error.message}`);
|
||||
alert(`Matting process failed:\n\n${error.message}`);
|
||||
} finally {
|
||||
button.classList.remove('loading');
|
||||
button.removeChild(spinner);
|
||||
|
||||
Reference in New Issue
Block a user