-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathExceptionHandling.cs
35 lines (34 loc) · 1.13 KB
/
ExceptionHandling.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using System.IO;
namespace Ionide.ProjInfo.Sln.Shared
{
internal static class ExceptionHandling
{
/// <summary>
/// Determine whether the exception is file-IO related.
/// </summary>
/// <param name="e">The exception to check.</param>
/// <returns>True if exception is IO related.</returns>
public static bool IsIoRelatedException(Exception e)
{
// These all derive from IOException
// DirectoryNotFoundException
// DriveNotFoundException
// EndOfStreamException
// FileLoadException
// FileNotFoundException
// PathTooLongException
// PipeException
return e is UnauthorizedAccessException
|| e is NotSupportedException
|| (e is ArgumentException && !(e is ArgumentNullException))
|| e is SecurityException
|| e is IOException;
}
}
}