-
Notifications
You must be signed in to change notification settings - Fork 186
/
SharePointRestServiceException.cs
48 lines (43 loc) · 1.81 KB
/
SharePointRestServiceException.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
using System;
using System.Collections.Generic;
namespace PnP.Core
{
/// <summary>
/// Microsoft SharePoint REST Service exception
/// </summary>
public class SharePointRestServiceException : ServiceException
{
#region Default exception constructors
internal SharePointRestServiceException(string message) : base(message)
{
}
internal SharePointRestServiceException(string message, Exception innerException) : base(message, innerException)
{
}
internal SharePointRestServiceException()
{
}
#endregion
#region Custom constructors
/// <summary>
/// Creates a <see cref="SharePointRestServiceException"/> 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 service request</param>
/// <param name="response">Response of the service request that errored out</param>
/// <param name="responseHeaders">Optional collection of request response headers</param>
public SharePointRestServiceException(ErrorType type, int httpResponseCode, string response, Dictionary<string, string> responseHeaders = null) : base("SharePoint Rest service exception")
{
Error = new SharePointRestError(type, httpResponseCode, response, responseHeaders);
}
#endregion
/// <summary>
/// Outputs a <see cref="SharePointRestServiceException"/> to a string representation
/// </summary>
/// <returns>String representation</returns>
public override string ToString()
{
return $"{Error?.ToString()}{Environment.NewLine}{base.ToString()}";
}
}
}