forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvalidByteRangeException.cs
More file actions
58 lines (51 loc) · 2.33 KB
/
InvalidByteRangeException.cs
File metadata and controls
58 lines (51 loc) · 2.33 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
51
52
53
54
55
56
57
58
// 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.Http.Headers;
using System.Runtime.Serialization;
using System.Web.Http;
namespace System.Net.Http
{
/// <summary>
/// An exception thrown by <see cref="ByteRangeStreamContent"/> in case none of the requested ranges
/// overlap with the current extend of the selected resource. The current extend of the resource
/// is indicated in the ContentRange property.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "Exception is not intended to be serialized.")]
[SuppressMessage("Microsoft.Usage", "CA2240:ImplementISerializableCorrectly", Justification = "Exception is not intended to be serialized.")]
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "The ContentRange is a required parameter.")]
public class InvalidByteRangeException : Exception
{
public InvalidByteRangeException(ContentRangeHeaderValue contentRange)
{
Initialize(contentRange);
}
public InvalidByteRangeException(ContentRangeHeaderValue contentRange, string message)
: base(message)
{
Initialize(contentRange);
}
public InvalidByteRangeException(ContentRangeHeaderValue contentRange, string message, Exception innerException)
: base(message, innerException)
{
Initialize(contentRange);
}
public InvalidByteRangeException(ContentRangeHeaderValue contentRange, SerializationInfo info, StreamingContext context)
: base(info, context)
{
Initialize(contentRange);
}
/// <summary>
/// The current extend of the resource indicated in terms of a ContentRange header field.
/// </summary>
public ContentRangeHeaderValue ContentRange { get; private set; }
private void Initialize(ContentRangeHeaderValue contentRange)
{
if (contentRange == null)
{
throw Error.ArgumentNull("contentRange");
}
ContentRange = contentRange;
}
}
}