/
InstagramHttpException.cs
63 lines (48 loc) · 1.9 KB
/
InstagramHttpException.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
using System;
using Skybrud.Social.Http;
using Skybrud.Social.Instagram.Models;
using Skybrud.Social.Instagram.Models.Common;
namespace Skybrud.Social.Instagram.Exceptions {
/// <summary>
/// Class representing an exception/error returned by the Instagram API.
/// </summary>
public class InstagramHttpException : Exception {
#region Properties
/// <summary>
/// Gets a reference to the underlying <see cref="SocialHttpResponse"/>.
/// </summary>
public SocialHttpResponse Response { get; private set; }
/// <summary>
/// Gets information about rate limiting.
/// </summary>
public InstagramRateLimiting RateLimiting { get; private set; }
/// <summary>
/// Gets whether rate limiting information was included in the response.
/// </summary>
public bool HasRateLimiting {
get { return RateLimiting.Limit > 0; }
}
/// <summary>
/// Gets the meta data of the response.
/// </summary>
public InstagramMetaData Meta { get; private set; }
/// <summary>
/// Gets whether meta data was included in the response.
/// </summary>
public bool HasMeta {
get { return Meta != null; }
}
#endregion
#region Constructors
internal InstagramHttpException(SocialHttpResponse response) : base("Invalid response received from the Instagram API (Status: " + ((int) response.StatusCode) + ")") {
Response = response;
RateLimiting = InstagramRateLimiting.GetFromResponse(response);
}
internal InstagramHttpException(SocialHttpResponse response, InstagramMetaData meta) : base(meta.ErrorMessage) {
Response = response;
RateLimiting = InstagramRateLimiting.GetFromResponse(response);
Meta = meta;
}
#endregion
}
}