Skip to content

Commit

Permalink
refactor: update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Mar 17, 2024
1 parent 185f938 commit e2c26b2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/LangGraph/LangGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,19 @@ public class GraphState<State: AgentState> {
for edge in edges {

guard nodes.contains( makeFakeNode(edge.sourceId) ) else {
throw GraphStateError.missingNodeReferencedByEdge( "edge sourceId: \(edge.sourceId) reference a not existent node!")
throw GraphStateError.missingNodeReferencedByEdge( "edge sourceId: \(edge.sourceId) reference to non existent node!")
}

switch( edge.target ) {
case .id( let targetId ):
guard targetId==END || nodes.contains(makeFakeNode(targetId) ) else {
throw GraphStateError.missingNodeReferencedByEdge( "edge sourceId: \(edge.sourceId) reference a not existent targetId: \(targetId) node!")
throw GraphStateError.missingNodeReferencedByEdge( "edge sourceId: \(edge.sourceId) reference to non existent node targetId: \(targetId) node!")
}
break
case .condition((_, let edgeMappings)):
for (_,nodeId) in edgeMappings {
guard nodeId==END || nodes.contains(makeFakeNode(nodeId) ) else {
throw GraphStateError.missingNodeInEdgeMapping( "edge mapping for sourceId: \(edge.sourceId) contains a not existen nodeId \(nodeId)!")
throw GraphStateError.missingNodeInEdgeMapping( "edge mapping for sourceId: \(edge.sourceId) contains a not existent nodeId \(nodeId)!")
}
}
}
Expand Down

0 comments on commit e2c26b2

Please sign in to comment.