{"record":{"id":"e4022bd6e483ab3b","repo":"nautechsystems/nautilus_trader","slug":"event-should-have-associated-handler","errorCode":null,"errorMessage":"Event '{}' should have associated handler","messagePattern":"Event '(.+?)' should have associated handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/clock.rs","lineNumber":769,"sourceCode":"    /// Returns the callback for `name`, falling back to the default callback.\n    #[must_use]\n    pub fn get_callback(&self, name: &Ustr) -> Option<TimeEventCallback> {\n        self.callbacks\n            .get(name)\n            .cloned()\n            .or_else(|| self.default_callback.clone())\n    }\n\n    /// Creates a handler for `event` using its named callback or the default callback.\n    ///\n    /// # Panics\n    ///\n    /// Panics if neither a named nor default callback exists for the event.\n    #[must_use]\n    pub fn get_handler(&self, event: TimeEvent) -> TimeEventHandler {\n        let callback = self\n            .get_callback(&event.name)\n            .unwrap_or_else(|| panic!(\"Event '{}' should have associated handler\", event.name));\n\n        TimeEventHandler::new(event, callback)\n    }\n\n    /// Clears all named callbacks, preserving the default callback.\n    pub fn clear(&mut self) {\n        self.callbacks.clear();\n    }\n}\n\n/// Validates and normalizes parameters for a time alert.\n///\n/// `allow_past` defaults to `true`. When enabled, a past alert timestamp is replaced with\n/// `ts_now`. Returns the interned name and normalized alert timestamp.\n///\n/// # Errors\n///\n/// Returns an error if `name` is invalid or the alert is in the past when past alerts are","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/clock.rs#L751-L787","documentation":"LiveClock::get_handler resolves the callback for a TimeEvent by its event name, panicking when neither a named callback nor a default callback was registered for that name. Timers created with a name expect a matching set_callback(name, ...) registration before the timer fires.","triggerScenarios":"Registering a timer with set_timer(name, ...) (or set_time_alert) but never calling set_callback with the same name; calling clear() which removes named callbacks while timers are still pending; a name mismatch between timer registration and callback registration.","commonSituations":"Actor restart/reconnect paths that clear callbacks but leave timers scheduled; renaming a timer in one place but not the callback registration; timers left running during shutdown when the event still fires.","solutions":["Register a callback for the exact event name with set_callback before the timer can fire","Register a default callback so unmatched named events still have a handler","Do not call clear() while timers with named callbacks are still pending, or re-register callbacks after clearing","Verify the timer name string matches the callback name exactly"],"exampleFix":"// before\nclock.set_timer(\"my-timer\", interval);\n// after\nclock.set_timer(\"my-timer\", interval);\nclock.set_callback(\"my-timer\", Box::new(|event| { /* handle */ }));","handlingStrategy":"validation","validationCode":"// before scheduling, ensure a callback exists for the name\nclock.set_callback(\"my-timer\", Box::new(handle_event));\nclock.set_timer(\"my-timer\", interval);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair every set_timer/set_time_alert call with a set_callback using the identical name string","Never call clear() while named timers are outstanding without re-registering callbacks","Define timer names as constants to avoid string mismatches"],"tags":["rust","clock","timer","panic","missing-handler"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}