{"record":{"id":"fa74855e6d3749ba","repo":"dotnet/wpf","slug":"animation-exception","errorCode":"Animation_Exception","errorMessage":"SR.Animation_Exception (Animation_Exception)","messagePattern":"SR\\.Animation_Exception \\(Animation_Exception\\)","errorType":"exception","errorClass":"AnimationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/AnimationStorage.cs","lineNumber":485,"sourceCode":"                        if (TraceAnimation.IsEnabled)\n                        {\n                            TraceAnimation.TraceActivityItem(\n                                TraceAnimation.AnimateStorageValidationFailed,\n                                this,\n                                animatedValue,\n                                target,\n                                _dependencyProperty);\n                        }\n\n                        _hadValidationError = true;\n                    }\n                }\n                catch (Exception e)\n                {\n                    // Catch all exceptions thrown during the InvalidateProperty callstack\n                    // and wrap them in an AnimationException\n\n                    throw new AnimationException(\n                        (AnimationClock)sender,\n                        _dependencyProperty,\n                        (IAnimatable)target,\n                        SR.Format(\n                            SR.Animation_Exception,\n                            _dependencyProperty.Name,\n                            target.GetType().FullName,\n                            ((AnimationClock)sender).Timeline.GetType().FullName),\n                        e);\n                }\n            }\n        }\n\n        private void OnRemoveRequested(object sender, EventArgs args)\n        {\n            Debug.Assert(   _animationClocks != null\n                         && _animationClocks.Count > 0,\n                \"An AnimationClock no longer associated with a property should not have a RemoveRequested event handler.\");","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/AnimationStorage.cs#L467-L503","documentation":"An exception escaped from the InvalidateProperty call stack while applying an animated value to the target property. AnimationStorage catches any exception and rethrows it wrapped as an AnimationException carrying the clock, property, and target, with SR.Animation_Exception as the message.","triggerScenarios":"Applying an animation whose calculated value causes the property setter/coercion/validation to throw; a clock's current-time invalidation callback failing while updating the dependency property.","commonSituations":"Custom animations or CoerceValueCallback/ValidateValueCallback throwing; animating properties whose setters have side effects; data-binding converters failing during animation updates.","solutions":["Inspect the InnerException to find the original failure and fix the throwing property/coercion code","Add validation in the custom animation so invalid values never reach the property","Wrap animation start points (BeginAnimation) in try/catch AnimationException for diagnostics"],"exampleFix":"// before\nstoryboard.Begin(this); // AnimationException at runtime\n// after\ntry { storyboard.Begin(this); }\ncatch (AnimationException ex) { log.Error($\"Animation failed on {ex.Property.Name}: {ex.InnerException}\"); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { storyboard.Begin(target); }\ncatch (AnimationException ex) { log.Error($\"{ex.Property.Name} failed: {ex.InnerException?.Message}\"); }","preventionTips":["Always inspect InnerException of AnimationException","Avoid throwing from property coercion/validation callbacks during animation","Test custom animations against target properties before shipping"],"tags":["wpf","animation","wrapped-exception"],"backgroundTag":"unexpected-response-shape","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}