-
Notifications
You must be signed in to change notification settings - Fork 1
/
PortableTimestampOverflowException.cs
55 lines (48 loc) · 2.01 KB
/
PortableTimestampOverflowException.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
49
50
51
52
53
54
55
using System;
using JetBrains.Annotations;
namespace HpTimeStamps
{
/// <summary>
/// Indicates that a portable timestamp cannot be converted to a local
/// monotonic stamp or a local datetime or timespan because of overflow.
/// </summary>
public sealed class PortableTimestampOverflowException : ApplicationException
{
/// <summary>
/// Create an exception
/// </summary>
public PortableTimestampOverflowException()
: this(null, null) {}
/// <summary>
/// Create an exception
/// </summary>
/// <param name="inner">inner exception, if applicable</param>
public PortableTimestampOverflowException([CanBeNull] Exception inner)
: this(null, inner) {}
/// <summary>
/// Create an exception
/// </summary>
/// <param name="msg">extra info to go in exception message, if applicable.</param>
public PortableTimestampOverflowException([CanBeNull] string msg)
: this(msg, null) {}
/// <summary>
/// Create an exception
/// </summary>
/// <param name="msg">Extra info that should go in message, if applicable</param>
/// <param name="inner">Inner exception if applicable</param>
public PortableTimestampOverflowException([CanBeNull] string msg, [CanBeNull] Exception inner)
: base(CreateMessage(msg, inner), inner) {}
private static string CreateMessage([CanBeNull] string extraInfo, [CanBeNull] Exception inner)
{
string extraStr = !string.IsNullOrWhiteSpace(extraInfo)
? " Extra information: \"" + extraInfo + "\"."
: string.Empty;
if (inner != null)
{
extraStr += " Consult inner exception for details.";
}
return string.Format(ExMsgFrmtStr, extraStr);
}
private const string ExMsgFrmtStr = @"Overflow occured when attempting to perform a conversion operation.{0}";
}
}