Skip to content

Commit 5565677

Browse files
committed
validation errors typed
1 parent 06ddd80 commit 5565677

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,12 @@ export function useWorkflowExecution() {
789789
const startBlock = TriggerUtils.findStartBlock(filteredStates, 'chat')
790790

791791
if (!startBlock) {
792-
throw new Error(TriggerUtils.getTriggerValidationMessage('chat', 'missing'))
792+
throw new WorkflowValidationError(
793+
TriggerUtils.getTriggerValidationMessage('chat', 'missing'),
794+
'validation',
795+
'validation',
796+
'Workflow Validation'
797+
)
793798
}
794799

795800
startBlockId = startBlock.blockId
@@ -800,7 +805,12 @@ export function useWorkflowExecution() {
800805
})
801806

802807
if (candidates.length === 0) {
803-
const error = new Error('Workflow requires at least one trigger block to execute')
808+
const error = new WorkflowValidationError(
809+
'Workflow requires at least one trigger block to execute',
810+
'validation',
811+
'validation',
812+
'Workflow Validation'
813+
)
804814
logger.error('No trigger blocks found for manual run', {
805815
allBlockTypes: Object.values(filteredStates).map((b) => b.type),
806816
})
@@ -813,7 +823,12 @@ export function useWorkflowExecution() {
813823
(candidate) => candidate.path === StartBlockPath.SPLIT_API
814824
)
815825
if (apiCandidates.length > 1) {
816-
const error = new Error('Multiple API Trigger blocks found. Keep only one.')
826+
const error = new WorkflowValidationError(
827+
'Multiple API Trigger blocks found. Keep only one.',
828+
'validation',
829+
'validation',
830+
'Workflow Validation'
831+
)
817832
logger.error('Multiple API triggers found')
818833
setIsExecuting(false)
819834
throw error
@@ -833,7 +848,12 @@ export function useWorkflowExecution() {
833848
const outgoingConnections = workflowEdges.filter((edge) => edge.source === startBlockId)
834849
if (outgoingConnections.length === 0) {
835850
const triggerName = selectedTrigger.name || selectedTrigger.type
836-
const error = new Error(`${triggerName} must be connected to other blocks to execute`)
851+
const error = new WorkflowValidationError(
852+
`${triggerName} must be connected to other blocks to execute`,
853+
'validation',
854+
'validation',
855+
'Workflow Validation'
856+
)
837857
logger.error('Trigger has no outgoing connections', { triggerName, startBlockId })
838858
setIsExecuting(false)
839859
throw error
@@ -859,7 +879,12 @@ export function useWorkflowExecution() {
859879

860880
// If we don't have a valid startBlockId at this point, throw an error
861881
if (!startBlockId) {
862-
const error = new Error('No valid trigger block found to start execution')
882+
const error = new WorkflowValidationError(
883+
'No valid trigger block found to start execution',
884+
'validation',
885+
'validation',
886+
'Workflow Validation'
887+
)
863888
logger.error('No startBlockId found after trigger search')
864889
setIsExecuting(false)
865890
throw error

0 commit comments

Comments
 (0)