-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathOAuthException.cs
95 lines (82 loc) · 2.76 KB
/
OAuthException.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Text;
namespace RenRen.Plurk
{
/// <summary>Occurs when an OAuth request encounters an error.</summary>
[Serializable]
public class OAuthException : ApplicationException
{
public OAuthException()
: base("An error occured during OAuth authentication")
{
}
public OAuthException(string message)
: base(message)
{
}
public OAuthException(string message, Exception innerException)
: base(message, innerException)
{
}
}
/// <summary>Occurs when an OAuth request encounters authorization error (401).</summary>
[Serializable]
public class OAuthAuthorizationException : OAuthException
{
public OAuthAuthorizationException()
: base("OAuth authorization error")
{
}
public OAuthAuthorizationException(string message)
: base(message)
{
}
public OAuthAuthorizationException(string message, Exception innerException)
: base(message, innerException)
{
}
}
/// <summary>Occurs when an OAuth request was rejected due to
/// nonce or timestamp invalidity.</summary>
[Serializable]
public class OAuthNonceException : OAuthException
{
public OAuthNonceException()
: base("Invalid nonce or timestamp in an OAuth request")
{
}
public OAuthNonceException(string nonce, string timestamp)
: this()
{
Nonce = nonce;
Timestamp = timestamp;
Data.Add("Nonce", nonce);
Data.Add("Timestamp", timestamp);
}
/// <summary>Gets the last known nonce of the OAuthInstance.</summary>
public string Nonce { get; private set; }
/// <summary>Gets the last known timestamp of the OAuthInstance.</summary>
public string Timestamp { get; private set; }
}
/// <summary>Occurs when an OAuth request encounters an error.
/// This class is thrown only when the server returned further
/// information during 400 Bad Request.</summary>
[Serializable]
public class OAuthRequestException : OAuthException
{
public OAuthRequestException(string response)
: base("Bad OAuth request")
{
ResponseData = response;
Data.Add("ResponseData", response);
}
public OAuthRequestException(string response, Exception innerException)
: base("Bad OAuth request", innerException)
{
ResponseData = response;
}
/// <summary>Gets the text representation of server response.</summary>
public string ResponseData { get; private set; }
}
}