More consistent error handling in modelingMachine codemods (#6910)
* First pass at consistency in modelingMachine codemods
* Add 'no kcl errors' guard instead of if check for all the existing ones
* Add more commands and improve consistency
* Add comments
* Fix test with old kcl that was showcasing the very behavior we're trying to fix
https://kittycadworkspace.slack.com/archives/C07A80B83FS/p1747231832870739?thread_ts=1747231178.515289&cid=C07A80B83FS
* Add test for sketch and helix
* Remove guard use and move hasErrors check closer to updateAst calls
* Revert "Remove guard use and move hasErrors check closer to updateAst calls"
This reverts commit 868ea4b605
.
* Remove toasts from guards
* Remove some scene.settled calls
* Lint
* More shaky fixes
* Clean up and more test fixes
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
This commit is contained in:
@ -580,24 +580,23 @@ export const ModelingMachineProvider = ({
|
||||
selectionRanges
|
||||
)
|
||||
},
|
||||
'Has exportable geometry': () => {
|
||||
if (!kclManager.hasErrors() && kclManager.ast.body.length > 0)
|
||||
return true
|
||||
else {
|
||||
let errorMessage = 'Unable to Export '
|
||||
if (kclManager.hasErrors()) errorMessage += 'due to KCL Errors'
|
||||
else if (kclManager.ast.body.length === 0)
|
||||
errorMessage += 'due to Empty Scene'
|
||||
console.error(errorMessage)
|
||||
toast.error(errorMessage)
|
||||
return false
|
||||
}
|
||||
},
|
||||
'Has exportable geometry': () =>
|
||||
!kclManager.hasErrors() && kclManager.ast.body.length > 0,
|
||||
},
|
||||
actors: {
|
||||
exportFromEngine: fromPromise(
|
||||
async ({ input }: { input?: ModelingCommandSchema['Export'] }) => {
|
||||
if (!input) {
|
||||
if (kclManager.hasErrors() || kclManager.ast.body.length === 0) {
|
||||
let errorMessage = 'Unable to Export '
|
||||
if (kclManager.hasErrors()) {
|
||||
errorMessage += 'due to KCL Errors'
|
||||
} else if (kclManager.ast.body.length === 0) {
|
||||
errorMessage += 'due to Empty Scene'
|
||||
}
|
||||
console.error(errorMessage)
|
||||
toast.error(errorMessage)
|
||||
return new Error(errorMessage)
|
||||
} else if (!input) {
|
||||
return new Error('No input provided')
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user