a-b-street/abstreet · error
doesn't touch
Error message
{} doesn't touch {} What it means
other_endpt is called with an IntersectionID that is neither this road's src_i nor dst_i, so the road has no 'other' endpoint to return. The caller assumed the road touches the given intersection, but it doesn't — usually a mixup of road/intersection IDs or a caller that skipped checking road.endpoints().
Solutions
- Check src_i == i || dst_i == i before the call, or obtain the intersection from road.src_i/dst_i directly.
- Use the road's own endpoint fields instead of a separately tracked intersection ID.
- Avoid persisting map-local IDs across reloads; look them up fresh.
Example fix
// before
let other = road.other_endpt(i);
// after
let other = if road.src_i == i { road.dst_i } else if road.dst_i == i { road.src_i } else { anyhow::bail!("{} not endpoint of {}", i, road.id) }; Defensive patterns
Strategy: type-guard
Type guard
fn other_endpt_safe(road: &Road, i: IntersectionID) -> Option<IntersectionID> {
if road.src_i == i { Some(road.dst_i) }
else if road.dst_i == i { Some(road.src_i) }
else { None }
} Prevention
- Iterate road.src_i/dst_i directly in traversal code
- Check incidence (src_i == i || dst_i == i) before endpoint helpers
- Refresh all IDs after map regeneration
When it happens
Trigger: Calling road.other_endpt(i) with an intersection not equal to src_i or dst_i — often from iterating intersections adjacent to a node and confusing road/intersection pairs, or stale IDs after regeneration.
Common situations: Graph traversal code building turns or shortest paths; manual construction of movement data; IDs carried across map reloads.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- doesn't contain
- doesn't point to
- doesn't have an endpoint at
- isn't an endpoint of
- must_get_sidewalk broken by
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/a9b0281cd39f0b3f.
Report an issue: GitHub.
Appendix: source
Thrown at map_model/src/objects/road.rs:490
pub fn other_endpt(&self, i: IntersectionID) -> IntersectionID {
if self.src_i == i {
self.dst_i
} else if self.dst_i == i {
self.src_i
} else {
panic!("{} doesn't touch {}", self.id, i);
}
}View on GitHub (pinned to 0964f29315)