-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDropboxExceptionExtensions.cs
78 lines (58 loc) · 1.56 KB
/
DropboxExceptionExtensions.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using Dropbox.Api;
namespace PneumaticTube
{
internal static class DropboxExceptionExtensions
{
public static ExitCode? HandleAuthException(this DropboxException ex)
{
var authException = ex as AuthException;
if (authException == null)
{
return null;
}
Console.WriteLine($"An authentication error occurred: {authException}");
return ExitCode.AccessDenied;
}
public static ExitCode? HandleAccessException(this DropboxException ex)
{
var accessException = ex as AccessException;
if (accessException == null)
{
return null;
}
Console.WriteLine($"An access error occurred: {accessException}");
return ExitCode.AccessDenied;
}
public static ExitCode? HandleRateLimitException(this DropboxException ex)
{
var rateLimitException = ex as RateLimitException;
if (rateLimitException == null)
{
return null;
}
Console.WriteLine($"A rate limit error occurred: {rateLimitException}");
return ExitCode.Canceled;
}
public static ExitCode? HandleBadInputException(this DropboxException ex)
{
var badInputException = ex as BadInputException;
if (badInputException == null)
{
return null;
}
Console.WriteLine($"An error occurred: {badInputException}");
return ExitCode.BadArguments;
}
public static ExitCode? HandleHttpException(this DropboxException ex)
{
var httpException = ex as HttpException;
if (httpException == null)
{
return null;
}
Console.WriteLine($"An HTTP error occurred: {httpException}");
return ExitCode.BadArguments;
}
}
}