From b26c8e3b9e85c09c908332c52704aa552a2170e3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Aug 2018 14:02:49 +0900 Subject: [PATCH 1/2] Fix notifiation stack trace output on mania conversion failure --- .../Beatmaps/Patterns/PatternGenerator.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 3434c9f01e..1f416f921e 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -55,15 +55,18 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns { int iterations = 0; - while (condition() && iterations++ < max_rng_iterations) + while (condition()) + { + if (iterations++ >= max_rng_iterations) + { + // log an error but don't throw. we want to continue execution. + Logger.Error(new ExceededAllowedIterationsException(new StackTrace(0)), + "Conversion encountered errors. The beatmap may not be correctly converted."); + return; + } + action(); - - if (iterations < max_rng_iterations) - return; - - // Generate + log an error/stacktrace - - Logger.Log($"Allowable iterations ({max_rng_iterations}) exceeded:\n{new StackTrace(0)}", level: LogLevel.Error); + } } /// @@ -71,5 +74,20 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// /// The s containing the hit objects. public abstract IEnumerable Generate(); + + /// + /// Denotes when a single conversion operation is in an infinitely looping state. + /// + public class ExceededAllowedIterationsException : Exception + { + private readonly string stackTrace; + + public ExceededAllowedIterationsException(StackTrace stackTrace) + { + this.stackTrace = stackTrace.ToString(); + } + + public override string StackTrace => stackTrace; + } } } From dfecb3235b7d3d0bbf0d694f1528071aa87e61b0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Aug 2018 20:41:53 +0900 Subject: [PATCH 2/2] Fix custom exception stack trace output --- osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 1f416f921e..1eb0cdae2f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -88,6 +88,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns } public override string StackTrace => stackTrace; + public override string ToString() => $"{GetType().Name}: {Message}\r\n{StackTrace}"; } } }