Check-in [6cdbea3412]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Better reporting of Uglify errors.
Timelines: family | ancestors | descendants | both | dotnet
Files: files | file ages | folders
SHA1: 6cdbea3412d8d1345fb9206d2a33e9365935d25a
User & Date: tinus 2019-09-14 05:53:48
Wiki:dotnet
Context
2019-09-14
06:18
Handle errors within each Populate* function, so the other ones get executed anyway. check-in: 02809ed40d user: tinus tags: dotnet
05:54
Merge dotnet into dotnet/timers (error reporting improvements). Leaf check-in: 1e71405b77 user: tinus tags: dotnet/timers
05:53
Better reporting of Uglify errors. check-in: 6cdbea3412 user: tinus tags: dotnet
2019-09-13
20:46
Check for errors in Uglify output. check-in: 87b1f645a6 user: tinus tags: dotnet
Changes

Changes to MailSynchronizer.cs.

521
522
523
524
525
526
527
528


529
530
531
532








533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
                try
                {
                    try
                    {
                        var result = NUglify.Uglify.HtmlToText(sourceMsg.HtmlBody, NUglify.Html.HtmlToTextOptions.KeepStructure);
                        if (result.Code == null && result.HasErrors)
                        {
                            throw new AggregateException(result.Errors.Select(e => new Exception($"Error {e.ErrorCode} at line {e.StartLine}, column {e.StartColumn}: {e.Message}")


                            {
                                Source = nameof(NUglify.Uglify),
                                //HResult = e.ErrorNumber,
                            }));








                        }
                        bodyText += result.Code.Trim();
                        return bodyText;
                    }
                    catch (Exception ex)
                    {
                        errors.Add(ex);
                    }
                    try
                    {
                        var html = sourceMsg.HtmlBody;
                        // The HtmlConverter is known to sometimes get stuck in an infinite loop, so wait for a finite amount of time
                        using(var timeoutTokenSource = new CancellationTokenSource())
                        {
                            var task = Task.Run(() => new ReverseMarkdown.Converter(_htmlConverterConfig).Convert(html).TrimEnd(), timeoutTokenSource.Token);
                            if (task.Wait(300000))
                            {
                                task.Dispose();
                            }







|
>
>
|
|
<
|
>
>
>
>
>
>
>
>











|







521
522
523
524
525
526
527
528
529
530
531
532

533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
                try
                {
                    try
                    {
                        var result = NUglify.Uglify.HtmlToText(sourceMsg.HtmlBody, NUglify.Html.HtmlToTextOptions.KeepStructure);
                        if (result.Code == null && result.HasErrors)
                        {
                            var errList = result.Errors.Select(error =>
                                new Exception($"Error {error.ErrorCode} ({error.ErrorNumber}) between line {error.StartLine},"
                                            + $" column {error.StartColumn} and line {error.EndLine}, column {error.EndColumn}: {error.Message}")
                                {
                                    Source = nameof(NUglify.Uglify),

                                });
                            if (errList.Count() == 1)
                            {
                                throw errList.First();
                            }
                            else
                            {
                                throw new AggregateException(errList);
                            }
                        }
                        bodyText += result.Code.Trim();
                        return bodyText;
                    }
                    catch (Exception ex)
                    {
                        errors.Add(ex);
                    }
                    try
                    {
                        var html = sourceMsg.HtmlBody;
                        // This HtmlConverter is known to sometimes get stuck in an infinite loop, so wait for a finite amount of time
                        using(var timeoutTokenSource = new CancellationTokenSource())
                        {
                            var task = Task.Run(() => new ReverseMarkdown.Converter(_htmlConverterConfig).Convert(html).TrimEnd(), timeoutTokenSource.Token);
                            if (task.Wait(300000))
                            {
                                task.Dispose();
                            }