44using MaIN . Domain . Entities ;
55using MaIN . Domain . Entities . Agents ;
66using MaIN . Domain . Entities . Agents . AgentSource ;
7+ using MaIN . Domain . Exceptions ;
78using MaIN . Services . Dtos ;
89using MaIN . Services . Mappers ;
910using MaIN . Services . Services . Abstract ;
@@ -210,7 +211,7 @@ public async Task<AgentFlow> CreateAsync()
210211 public async Task Delete ( )
211212 {
212213 if ( _flow . Id == null )
213- throw new InvalidOperationException ( "Flow has not been created yet." ) ;
214+ throw new FlowNotInitializedException ( ) ;
214215
215216 await _flowService . DeleteFlow ( _flow . Id ) ;
216217 }
@@ -219,7 +220,7 @@ public async Task Delete()
219220 public async Task < AgentFlow > GetCurrentFlow ( )
220221 {
221222 if ( _flow . Id == null )
222- throw new InvalidOperationException ( "Flow has not been created yet." ) ;
223+ throw new FlowNotInitializedException ( ) ;
223224
224225 return await _flowService . GetFlowById ( _flow . Id ) ;
225226 }
@@ -233,9 +234,8 @@ public async Task<List<AgentFlow>> GetAllFlows()
233234 public async Task < FlowContext > FromExisting ( string flowId )
234235 {
235236 var existingFlow = await _flowService . GetFlowById ( flowId ) ;
236- if ( existingFlow == null )
237- throw new ArgumentException ( "Flow not found" , nameof ( flowId ) ) ;
238-
239- return this ;
237+ return existingFlow == null
238+ ? throw new FlowFoundException ( flowId )
239+ : this ;
240240 }
241241}
0 commit comments