From 44ca50cb7d65bca13983def695844e311a6daf98 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 29 Sep 2017 20:20:34 +0200 Subject: [PATCH] File was not added --- src/Squidex.Infrastructure/ExceptionHelper.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Squidex.Infrastructure/ExceptionHelper.cs diff --git a/src/Squidex.Infrastructure/ExceptionHelper.cs b/src/Squidex.Infrastructure/ExceptionHelper.cs new file mode 100644 index 000000000..02b50998d --- /dev/null +++ b/src/Squidex.Infrastructure/ExceptionHelper.cs @@ -0,0 +1,27 @@ +// ========================================================================== +// ExceptionHelper.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +using System; + +namespace Squidex.Infrastructure +{ + public static class ExceptionHelper + { + public static bool Is(this Exception ex) where T : Exception + { + if (ex is AggregateException aggregateException) + { + aggregateException = aggregateException.Flatten(); + + return aggregateException.InnerExceptions.Count == 1 && Is(aggregateException.InnerExceptions[0]); + } + + return ex is OperationCanceledException; + } + } +}