Add error handling to register_timer