-
Notifications
You must be signed in to change notification settings - Fork 47
/
GithubException.cs
executable file
·59 lines (48 loc) · 1.1 KB
/
GithubException.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
using System;
using System.Collections.Generic;
namespace GithubSharp.Core
{
public class GithubException : Exception
{
public GithubException(System.Net.HttpWebResponse response, string uri)
:base(string.Format("Github error when retrieving {0}", uri))
{
var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
GithubErrorResult = GithubSharp.Core.Base.JsonConverter.FromJson<GithubErrorModel>(responseString);
StatusCode = (int)response.StatusCode;
StatusText = response.StatusDescription;
}
public GithubErrorModel GithubErrorResult { get;set;}
public int StatusCode { get;set;}
public string StatusText { get;set;}
}
public class GithubErrorResponse : GithubResponseWithReturnType<GithubErrorModel>
{
}
public class GithubErrorModel
{
public string message {
get;
set;
}
public IEnumerable<GithubErrorDetails> errors {
get;
set;
}
}
public class GithubErrorDetails
{
public string Resource {
get;
set;
}
public string Field {
get;
set;
}
public string Code {
get;
set;
}
}
}