forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpResponseException.cs
More file actions
50 lines (45 loc) · 2.17 KB
/
HttpResponseException.cs
File metadata and controls
50 lines (45 loc) · 2.17 KB
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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Web.Http.Properties;
namespace System.Web.Http
{
/// <summary>
/// An exception that allows for a given <see cref="HttpResponseMessage"/>
/// to be returned to the client.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "This type is not meant to be serialized")]
[SuppressMessage("Microsoft.Usage", "CA2240:Implement ISerializable correctly", Justification = "This type has no serializable state")]
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "HttpResponseException is not a real exception and is just an easy way to return HttpResponseMessage")]
public class HttpResponseException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="HttpResponseException"/> class.
/// </summary>
/// <param name="statusCode">The status code of the response.</param>
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Instance is disposed elsewhere")]
public HttpResponseException(HttpStatusCode statusCode)
: this(new HttpResponseMessage(statusCode))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpResponseException"/> class.
/// </summary>
/// <param name="response">The response message.</param>
public HttpResponseException(HttpResponseMessage response)
: base(SRResources.HttpResponseExceptionMessage)
{
if (response == null)
{
throw Error.ArgumentNull("response");
}
Response = response;
}
/// <summary>
/// Gets the <see cref="HttpResponseMessage"/> to return to the client.
/// </summary>
public HttpResponseMessage Response { get; private set; }
}
}