This repository was archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathDropboxException.cs
More file actions
75 lines (65 loc) · 2.23 KB
/
Copy pathDropboxException.cs
File metadata and controls
75 lines (65 loc) · 2.23 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
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
using System;
using System.Linq;
using RestSharp;
using System.Net;
namespace DropNet.Exceptions
{
public class DropboxException : Exception
{
public DropboxException()
{
}
public DropboxException(string message) : base(message)
{
}
}
public class DropboxRestException : DropboxException
{
/// <summary>
/// Returned status code from the request
/// </summary>
public HttpStatusCode StatusCode { get; set; }
/// <summary>
/// Expected status codes to have seen instead of the one recieved.
/// </summary>
public HttpStatusCode[] ExpectedCodes { get; private set; }
/// <summary>
/// The response of the error call (for Debugging use)
/// </summary>
public IRestResponse Response { get; private set; }
public DropboxRestException()
{
}
public DropboxRestException(string message)
: base(message)
{
}
/// <summary>
/// Creates a DropboxRestException with the rest response which caused the exception, and the status codes which were expected.
/// </summary>
/// <param name="r">Rest Response which was not expected.</param>
/// <param name="expectedCodes">The expected status codes which were not found.</param>
public DropboxRestException(IRestResponse r, params HttpStatusCode[] expectedCodes)
{
Response = r;
StatusCode = r.StatusCode;
ExpectedCodes = expectedCodes;
}
/// <summary>
/// Overridden message for Dropbox Exception.
/// <returns>
/// The exception message in the format of "Received Response [{0}] : Expected to see [{1}]. The HTTP response was [{2}].
/// </returns>
/// </summary>
public override string Message
{
get
{
return string.Format("Received Response [{0}] : Expected to see [{1}]. The HTTP response was [{2}].",
Response.StatusCode,
string.Join(", ", ExpectedCodes.Select(code => Enum.GetName(typeof(HttpStatusCode), code))),
Response.Content);
}
}
}
}