Skip to content

Commit

Permalink
add missing summary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianco Veigel committed May 19, 2017
1 parent b7fa0ad commit 09d3724
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Graphite/Exceptions/HttpRequestException.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Runtime.Serialization;

namespace ahd.Graphite.Exceptions
{
/// <summary>
/// A base class for exceptions thrown by the <see cref="System.Net.Http.HttpClient"/> and <see cref="System.Net.Http.HttpMessageHandler"/> classes.
/// </summary>
[Serializable]
public class HttpRequestException: System.Net.Http.HttpRequestException
{
/// <summary>
/// Initializes a new instance of the HttpRequestException class.
/// </summary>
/// <param name="statuscode">Statuscode of the response</param>
/// <param name="response">response content</param>
public HttpRequestException(HttpStatusCode statuscode, string response):base()
{
StatusCode = statuscode;
Response = response;
}

/// <summary>
/// Initializes a new instance of the HttpRequestException class with a specific message that describes the current exception
/// </summary>
/// <param name="response">response content</param>
/// <param name="message">exception message</param>
public HttpRequestException(string response, string message):base(message)
{
Response = response;
}

/// <summary>
/// Initializes a new instance of the HttpRequestException class with a specific message that describes the current exception and an inner exception.
/// </summary>
/// <param name="response">response content</param>
/// <param name="message">exception message</param>
/// <param name="inner">inner exception</param>
public HttpRequestException(string response, string message, Exception inner):base(message, inner)
{
Response = response;
}

/// <summary>
/// statuscode of the HTTP response
/// </summary>
public HttpStatusCode StatusCode { get; private set; }

/// <summary>
/// Content of the HTTP response
/// </summary>
public string Response { get; private set; }

/// <summary>
/// Security Critical. (Inherited from Exception.)
/// </summary>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
Expand All @@ -40,6 +69,10 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
base.GetObjectData(info, context);
}

/// <summary>
/// Initializes a new instance of the HttpRequestException class.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2236:CallBaseClassMethodsOnISerializableTypes", Justification = "base ctor is missing - blame Microsoft")]
protected HttpRequestException(SerializationInfo info, StreamingContext context)
{
Response = info.GetString(nameof(Response));
Expand Down
6 changes: 6 additions & 0 deletions Graphite/Exceptions/HttpResponseMessageExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

namespace ahd.Graphite.Exceptions
{
/// <summary>
/// Extensions for <see cref="HttpResponseMessage"/>
/// </summary>
public static class HttpResponseMessageExtension
{
/// <summary>
/// checks the statuscode and throws a <see cref="HttpRequestException"/> with the full response content
/// </summary>
public static async Task EnsureSuccessStatusCodeAsync(this HttpResponseMessage response)
{
if (response.IsSuccessStatusCode)
Expand Down

0 comments on commit 09d3724

Please sign in to comment.