-
Notifications
You must be signed in to change notification settings - Fork 139
/
NonNativeTokenException.cs
42 lines (38 loc) · 1.49 KB
/
NonNativeTokenException.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
using System;
using System.Runtime.Serialization;
using Libplanet.Serialization;
namespace Libplanet.Assets
{
/// <summary>
/// The exception that is thrown when a non-native asset is tried to be used for system actions.
/// </summary>
[Serializable]
public sealed class NonNativeTokenException : Exception
{
/// <summary>
/// Creates a new <see cref="NonNativeTokenException"/> instance.
/// </summary>
/// <param name="nonNativeToken">The non-native token which caused this exception.</param>
/// <param name="message">Specifies a <see cref="Exception.Message"/>.</param>
public NonNativeTokenException(Currency nonNativeToken, string? message = null)
: base(message)
{
NonNativeToken = nonNativeToken;
}
private NonNativeTokenException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
NonNativeToken = info.GetValue<Currency>(nameof(NonNativeToken));
}
/// <summary>
/// The non-native token which caused this exception.
/// </summary>
public Currency NonNativeToken { get; }
/// <inheritdoc cref="Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(NonNativeToken), NonNativeToken);
}
}
}