Bubble up the actual error message in the Text-to-CAD toast message (#7201)
So that users can see if they're blocked, for example.
This commit is contained in:
@ -15,7 +15,7 @@ import {
|
|||||||
SystemIOMachineEvents,
|
SystemIOMachineEvents,
|
||||||
waitForIdleState,
|
waitForIdleState,
|
||||||
} from '@src/machines/systemIO/utils'
|
} from '@src/machines/systemIO/utils'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { err, reportRejection } from '@src/lib/trap'
|
||||||
import { toSync } from '@src/lib/utils'
|
import { toSync } from '@src/lib/utils'
|
||||||
import { getAllSubDirectoriesAtProjectRoot } from '@src/machines/systemIO/snapshotContext'
|
import { getAllSubDirectoriesAtProjectRoot } from '@src/machines/systemIO/snapshotContext'
|
||||||
import { joinOSPaths } from '@src/lib/paths'
|
import { joinOSPaths } from '@src/lib/paths'
|
||||||
@ -120,12 +120,15 @@ export async function submitAndAwaitTextToKclSystemIO({
|
|||||||
return value
|
return value
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
showFailureToast('Failed to submit to Text-to-CAD API')
|
const message = err(error)
|
||||||
|
? error.message
|
||||||
|
: 'Failed to submit to Text-to-CAD API'
|
||||||
|
showFailureToast(message)
|
||||||
return error
|
return error
|
||||||
})
|
})
|
||||||
|
|
||||||
if (textToCadQueued instanceof Error) {
|
if (err(textToCadQueued)) {
|
||||||
showFailureToast('Failed to submit to Text-to-CAD API')
|
showFailureToast(textToCadQueued.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export function isErr<T>(value: ExcludeErr<T> | Error): value is Error {
|
|||||||
return value instanceof Error
|
return value instanceof Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to bubble errors up
|
/** Used to bubble errors up */
|
||||||
export function err<T>(value: ExcludeErr<T> | Error): value is Error {
|
export function err<T>(value: ExcludeErr<T> | Error): value is Error {
|
||||||
if (!isErr(value)) {
|
if (!isErr(value)) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user