{"record":{"id":"d2d9e7b9181c4a42","repo":"a-b-street/abstreet","slug":"not-a-carid","errorCode":null,"errorMessage":"Not a CarID: {:?}","messagePattern":"Not a CarID: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sim/src/lib.rs","lineNumber":140,"sourceCode":"impl AgentID {\n    pub(crate) fn as_car(self) -> CarID {\n        match self {\n            AgentID::Car(id) => id,\n            _ => panic!(\"Not a CarID: {:?}\", self),\n        }\n    }\n\n    pub fn to_type(self) -> AgentType {\n        match self {\n            AgentID::Car(c) => match c.vehicle_type {\n                VehicleType::Car => AgentType::Car,\n                VehicleType::Bike => AgentType::Bike,\n                VehicleType::Bus => AgentType::Bus,\n                VehicleType::Train => AgentType::Train,\n            },\n            AgentID::Pedestrian(_) => AgentType::Pedestrian,","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/sim/src/lib.rs#L122-L158","documentation":"Generic enum-variant unwrapping helper on AgentID: as_car asserts the agent is AgentID::Car and this panic fires when called on a Pedestrian or BusPassenger variant. The faulty input is the AgentID itself — the caller's routing logic sent a non-car agent to car-only code.","triggerScenarios":"Thrown at sim/src/lib.rs:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Match on AgentID explicitly or use to_type() to dispatch before calling as_car","Fix the caller so only car agents reach this code path","Return Option<CarID> from a new helper and handle non-car agents gracefully"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}