/
RegexParseException.cs
44 lines (38 loc) · 1.52 KB
/
RegexParseException.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Serialization;
namespace System.Text.RegularExpressions
{
/// <summary>
/// An exception as a result of a parse error in a regular expression <see cref="RegularExpressions"/>, with
/// detailed information in the <see cref="Error"/> and <see cref="Offset"/> properties.
/// </summary>
[Serializable]
#if REGEXGENERATOR
internal
#else
public
#endif
sealed class RegexParseException : ArgumentException
{
/// <summary>Gets the error that happened during parsing.</summary>
public RegexParseError Error { get; }
/// <summary>Gets the zero-based character offset in the regular expression pattern where the parse error occurs.</summary>
public int Offset { get; }
internal RegexParseException(RegexParseError error, int offset, string message) : base(message)
{
Error = error;
Offset = offset;
}
private RegexParseException(SerializationInfo info, StreamingContext context)
{
// It means someone modified the payload.
throw new NotImplementedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.SetType(typeof(ArgumentException)); // To maintain serialization support with .NET Framework.
}
}
}