@@ -101,9 +101,9 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
101101 const logger = createLogger ( 'EditWorkflowServerTool' )
102102 const { operations, workflowId, currentUserWorkflow } = params
103103 if ( ! Array . isArray ( operations ) || operations . length === 0 ) {
104- throw new Error ( 'operations are required and must be an array' )
104+ throw new OrchestrationError ( 'validation' , 'operations are required and must be an array' )
105105 }
106- if ( ! workflowId ) throw new Error ( 'workflowId is required' )
106+ if ( ! workflowId ) throw new OrchestrationError ( 'validation' , 'workflowId is required' )
107107 if ( ! context ?. userId ) {
108108 throw new Error ( 'Unauthorized workflow access' )
109109 }
@@ -135,7 +135,7 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
135135 operationsReferenceSimSandbox ( operations ) &&
136136 ( ! workspaceId || ! ( await hasWorkspaceSandboxAccess ( workspaceId ) ) )
137137 ) {
138- throw new Error ( MAX_PLAN_REQUIRED )
138+ throw new OrchestrationError ( 'forbidden' , MAX_PLAN_REQUIRED )
139139 }
140140
141141 logger . info ( 'Executing edit_workflow' , {
@@ -153,7 +153,7 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
153153 workflowState = JSON . parse ( currentUserWorkflow )
154154 } catch ( error ) {
155155 logger . error ( 'Failed to parse currentUserWorkflow' , error )
156- throw new Error ( 'Invalid currentUserWorkflow format' )
156+ throw new OrchestrationError ( 'validation' , 'Invalid currentUserWorkflow format' )
157157 }
158158 } else {
159159 const fromDb = await getCurrentWorkflowStateFromDb ( workflowId )
@@ -251,7 +251,10 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
251251 errors : validation . errors ,
252252 warnings : validation . warnings ,
253253 } )
254- throw new Error ( `Invalid edited workflow: ${ validation . errors . join ( '; ' ) } ` )
254+ throw new OrchestrationError (
255+ 'validation' ,
256+ `Invalid edited workflow: ${ validation . errors . join ( '; ' ) } `
257+ )
255258 }
256259
257260 if ( validation . warnings . length > 0 ) {
@@ -387,7 +390,7 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
387390 workflowId,
388391 error : saveResult . error ,
389392 } )
390- throw new Error ( `Failed to save workflow: ${ saveResult . error } ` )
393+ throw new OrchestrationError ( 'conflict' , `Failed to save workflow: ${ saveResult . error } ` )
391394 }
392395
393396 // Update workflow's lastSynced timestamp
0 commit comments