A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace DependencyInjectionException with rethrown exceptions

+4 -50
+1 -13
osu.Framework/Allocation/BackgroundDependencyLoaderAttribute.cs
··· 64 64 } 65 65 catch (TargetInvocationException exc) // During non-await invocations 66 66 { 67 - switch (exc.InnerException) 68 - { 69 - case OperationCanceledException _: 70 - // This activator is cancelled - propagate the cancellation as-is (it will be handled silently) 71 - throw exc.InnerException; 72 - 73 - case DependencyInjectionException die: 74 - // A nested activator has failed (multiple Invoke() calls) - propagate the original error 75 - throw die; 76 - } 77 - 78 - // This activator has failed (single reflection call) - preserve the original stacktrace while notifying of the error 79 - throw new DependencyInjectionException { DispatchInfo = ExceptionDispatchInfo.Capture(exc.InnerException) }; 67 + ExceptionDispatchInfo.Capture(exc.InnerException).Throw(); 80 68 } 81 69 }; 82 70
-10
osu.Framework/Allocation/DependencyActivator.cs
··· 5 5 using System.Collections.Concurrent; 6 6 using System.Collections.Generic; 7 7 using System.Reflection; 8 - using System.Runtime.ExceptionServices; 9 8 using osu.Framework.Extensions.TypeExtensions; 10 - using osu.Framework.Graphics; 11 9 using osu.Framework.Graphics.Containers; 12 10 13 11 namespace osu.Framework.Allocation ··· 155 153 : base(modifier, member, $"A property with an attached {nameof(ResolvedAttribute)} must have a private setter.") 156 154 { 157 155 } 158 - } 159 - 160 - /// <summary> 161 - /// Occurs when dependencies dependency injection into a <see cref="Drawable"/> fails. 162 - /// </summary> 163 - internal class DependencyInjectionException : Exception 164 - { 165 - public ExceptionDispatchInfo DispatchInfo; 166 156 } 167 157 168 158 internal delegate void InjectDependencyDelegate(object target, IReadOnlyDependencyContainer dependencies);
-2
osu.Framework/Allocation/DependencyContainer.cs
··· 180 180 /// </summary> 181 181 /// <typeparam name="T">The type of the instance to inject dependencies into.</typeparam> 182 182 /// <param name="instance">The instance to inject dependencies into.</param> 183 - /// <exception cref="DependencyInjectionException">When any user error has occurred. 184 - /// Rethrow <see cref="DependencyInjectionException.DispatchInfo"/> when appropriate to retrieve the original exception.</exception> 185 183 /// <exception cref="OperationCanceledException">When the injection process was cancelled.</exception> 186 184 public void Inject<T>(T instance) 187 185 where T : class
-1
osu.Framework/Graphics/Containers/CompositeDrawable.cs
··· 233 233 /// Loads a <see cref="Drawable"/> child. This will not throw in the event of the load being cancelled. 234 234 /// </summary> 235 235 /// <param name="child">The <see cref="Drawable"/> child to load.</param> 236 - /// <exception cref="DependencyInjectionException">When a user error occurred during dependency injection.</exception> 237 236 private void loadChild(Drawable child) 238 237 { 239 238 try
+2 -17
osu.Framework/Platform/GameHost.cs
··· 297 297 // Ensure we maintain a valid size for any children immediately scaling by the window size 298 298 Root.Size = Vector2.ComponentMax(Vector2.One, Root.Size); 299 299 300 - try 301 - { 302 - Root.UpdateSubTree(); 303 - } 304 - catch (DependencyInjectionException die) 305 - { 306 - die.DispatchInfo.Throw(); 307 - } 308 - 300 + Root.UpdateSubTree(); 309 301 Root.UpdateSubTreeMasking(Root, Root.ScreenSpaceDrawQuad.AABBFloat); 310 302 311 303 using (var buffer = DrawRoots.Get(UsageType.Write)) ··· 635 627 636 628 game.SetHost(this); 637 629 638 - try 639 - { 640 - root.Load(SceneGraphClock, Dependencies); 641 - } 642 - catch (DependencyInjectionException die) 643 - { 644 - die.DispatchInfo.Throw(); 645 - } 630 + root.Load(SceneGraphClock, Dependencies); 646 631 647 632 //publish bootstrapped scene graph to all threads. 648 633 Root = root;
-3
osu.Framework/Testing/Drawables/Steps/StepButton.cs
··· 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 4 using System; 5 - using osu.Framework.Allocation; 6 5 using osu.Framework.Graphics; 7 6 using osu.Framework.Graphics.Containers; 8 7 using osu.Framework.Graphics.Shapes; ··· 93 92 } 94 93 catch (Exception exc) 95 94 { 96 - if (exc.InnerException is DependencyInjectionException die) 97 - exc = die.DispatchInfo.SourceException; 98 95 Logging.Logger.Error(exc, $"Step {this} triggered an error"); 99 96 } 100 97
+1 -4
osu.Framework/Testing/TestSceneTestRunner.cs
··· 101 101 Scheduler.AddDelayed(complete, time_between_tests); 102 102 }, e => 103 103 { 104 - if (e is DependencyInjectionException die) 105 - exception = die.DispatchInfo; 106 - else 107 - exception = ExceptionDispatchInfo.Capture(e); 104 + exception = ExceptionDispatchInfo.Capture(e); 108 105 complete(); 109 106 }); 110 107 });