This repository was archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExceptionHelper.cs
More file actions
40 lines (32 loc) · 1.32 KB
/
Copy pathExceptionHelper.cs
File metadata and controls
40 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Text;
namespace Hspi
{
using Hspi.Exceptions;
using static System.FormattableString;
internal static class ExceptionHelper
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
public static string GetFullMessage(this Exception ex)
{
switch (ex)
{
case AggregateException aggregationException:
var stb = new StringBuilder();
foreach (var innerException in aggregationException.InnerExceptions)
{
stb.AppendLine(GetFullMessage(innerException));
}
return stb.ToString();
case ApiKeyInvalidException apiKeyInvalidException:
return Invariant($"Invalid API Key. Check Configuration.");
case StationIdInvalidException stationIdInvalidException:
return Invariant($"Station Is Not Valid or Offline. Check Configuration.");
case WUWeatherDataInvalidException weatherException:
return Invariant($"Failed to get Weather Information with {weatherException.Message}");
default:
return ex.Message;
}
}
};
}