11import { logger } from 'app/logging/logger' ;
22import { enqueueRequested } from 'app/store/actions' ;
33import type { AppStartListening } from 'app/store/middleware/listenerMiddleware' ;
4+ import { extractMessageFromAssertionError } from 'common/util/extractMessageFromAssertionError' ;
45import type { Result } from 'common/util/result' ;
56import { withResult , withResultAsync } from 'common/util/result' ;
67import { $canvasManager } from 'features/controlLayers/store/ephemeral' ;
@@ -9,10 +10,11 @@ import { buildFLUXGraph } from 'features/nodes/util/graph/generation/buildFLUXGr
910import { buildSD1Graph } from 'features/nodes/util/graph/generation/buildSD1Graph' ;
1011import { buildSDXLGraph } from 'features/nodes/util/graph/generation/buildSDXLGraph' ;
1112import type { Graph } from 'features/nodes/util/graph/generation/Graph' ;
13+ import { toast } from 'features/toast/toast' ;
1214import { serializeError } from 'serialize-error' ;
1315import { queueApi } from 'services/api/endpoints/queue' ;
1416import type { Invocation } from 'services/api/types' ;
15- import { assert } from 'tsafe' ;
17+ import { assert , AssertionError } from 'tsafe' ;
1618import type { JsonObject } from 'type-fest' ;
1719
1820const log = logger ( 'generation' ) ;
@@ -57,7 +59,17 @@ export const addEnqueueRequestedLinear = (startAppListening: AppStartListening)
5759 }
5860
5961 if ( buildGraphResult . isErr ( ) ) {
60- log . error ( { error : serializeError ( buildGraphResult . error ) } , 'Failed to build graph' ) ;
62+ let description : string | null = null ;
63+ if ( buildGraphResult . error instanceof AssertionError ) {
64+ description = extractMessageFromAssertionError ( buildGraphResult . error ) ;
65+ }
66+ const error = serializeError ( buildGraphResult . error ) ;
67+ log . error ( { error } , 'Failed to build graph' ) ;
68+ toast ( {
69+ status : 'error' ,
70+ title : 'Failed to build graph' ,
71+ description,
72+ } ) ;
6173 return ;
6274 }
6375
0 commit comments