Skip to content

Commit cea3cd5

Browse files
Mary HippMary Hipp
authored andcommitted
if backend returns an error, show it in toast
1 parent 8618e41 commit cea3cd5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

invokeai/frontend/web/src/services/events/util/setEventListeners.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
} from 'services/thunks/gallery';
2323
import { receivedModels } from 'services/thunks/model';
2424
import { receivedOpenAPISchema } from 'services/thunks/schema';
25+
import { makeToast } from '../../../features/system/hooks/useToastWatcher';
26+
import { addToast } from '../../../features/system/store/systemSlice';
2527

2628
type SetEventListenersArg = {
2729
socket: Socket<ServerToClientEvents, ClientToServerEvents>;
@@ -78,6 +80,16 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
7880
}
7981
});
8082

83+
socket.on('connect_error', (error) => {
84+
if (error && error.message) {
85+
dispatch(
86+
addToast(
87+
makeToast({ title: error.message, status: 'error', duration: 10000 })
88+
)
89+
);
90+
}
91+
});
92+
8193
/**
8294
* Disconnect
8395
*/

0 commit comments

Comments
 (0)