-
Notifications
You must be signed in to change notification settings - Fork 186
/
MicrosoftGraphServiceException.cs
58 lines (52 loc) · 2.28 KB
/
MicrosoftGraphServiceException.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.Text.Json;
namespace PnP.Core
{
/// <summary>
/// Microsoft Graph Service exception
/// </summary>
public class MicrosoftGraphServiceException : ServiceException
{
#region Default exception constructors
internal MicrosoftGraphServiceException(string message) : base(message)
{
}
internal MicrosoftGraphServiceException(string message, Exception innerException) : base(message, innerException)
{
}
internal MicrosoftGraphServiceException()
{
}
#endregion
#region Custom constructors
/// <summary>
/// Creates a <see cref="MicrosoftGraphServiceException"/> using the provided error type, http response code and request response
/// </summary>
/// <param name="type">Type of the error</param>
/// <param name="httpResponseCode">Http response code of the executed Graph request</param>
/// <param name="response">Response of the executed Graph request</param>
public MicrosoftGraphServiceException(ErrorType type, int httpResponseCode, string response) : base("Microsoft Graph service exception")
{
Error = new MicrosoftGraphError(type, httpResponseCode, response);
}
/// <summary>
/// Creates a <see cref="MicrosoftGraphServiceException"/> using the provided error type, http response code and request response
/// </summary>
/// <param name="type">Type of the error</param>
/// <param name="httpResponseCode">Http response code of the executed Graph request</param>
/// <param name="error">Json error coming from the executed Graph request</param>
public MicrosoftGraphServiceException(ErrorType type, int httpResponseCode, JsonElement error) : base("Microsoft Graph service exception")
{
Error = new MicrosoftGraphError(type, httpResponseCode, error);
}
#endregion
/// <summary>
/// Outputs a <see cref="MicrosoftGraphServiceException"/> to a string representation
/// </summary>
/// <returns>String representation</returns>
public override string ToString()
{
return $"{Error?.ToString()}{Environment.NewLine}{base.ToString()}";
}
}
}