Skip to content

Commit

Permalink
Avoid SerializationException when Exception deserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Jul 3, 2024
1 parent adc7c30 commit 509cc5b
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .Lib9c.Tests/Action/ExceptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Lib9c.Tests.Action
using MessagePack;
using MessagePack.Resolvers;
using Nekoyume.Action;
using Nekoyume.Action.Exceptions;
using Nekoyume.Action.Exceptions.AdventureBoss;
using Nekoyume.Exceptions;
using Nekoyume.Model.State;
using Nekoyume.TableData;
Expand Down Expand Up @@ -73,6 +75,15 @@ public ExceptionTest()
[InlineData(typeof(ItemNotFoundException))]
[InlineData(typeof(NotEnoughItemException))]
[InlineData(typeof(StateNullException))]
[InlineData(typeof(AlreadyClaimedException))]
[InlineData(typeof(ClaimExpiredException))]
[InlineData(typeof(InsufficientStakingException))]
[InlineData(typeof(InvalidAdventureBossSeasonException))]
[InlineData(typeof(InvalidBountyException))]
[InlineData(typeof(MaxInvestmentCountExceededException))]
[InlineData(typeof(PreviousBountyException))]
[InlineData(typeof(SeasonInProgressException))]
[InlineData(typeof(EmptyRewardException))]
public void Exception_Serializable(Type excType)
{
if (Activator.CreateInstance(excType, "for testing") is Exception exc)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class AlreadyClaimedException : Exception
{
public AlreadyClaimedException()
{
}

protected AlreadyClaimedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public AlreadyClaimedException(string msg) : base(msg)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class ClaimExpiredException : Exception
{
public ClaimExpiredException()
{
}

protected ClaimExpiredException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public ClaimExpiredException(string msg) : base(msg)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class InsufficientStakingException : Exception
{
public InsufficientStakingException()
{
}

protected InsufficientStakingException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public InsufficientStakingException(string msg) : base(msg)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class InvalidAdventureBossSeasonException : Exception
{
public InvalidAdventureBossSeasonException()
{
}

protected InvalidAdventureBossSeasonException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public InvalidAdventureBossSeasonException(string message) : base(message)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class InvalidBountyException : Exception
{
public InvalidBountyException()
{
}

protected InvalidBountyException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public InvalidBountyException(string msg) : base(msg)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class MaxInvestmentCountExceededException : Exception
{
public MaxInvestmentCountExceededException()
{
}

protected MaxInvestmentCountExceededException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public MaxInvestmentCountExceededException(string message) : base(message)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
Expand All @@ -8,5 +9,13 @@ public class PreviousBountyException : Exception
public PreviousBountyException(string msg) : base(msg)
{
}

public PreviousBountyException()
{
}

protected PreviousBountyException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions.AdventureBoss
{
[Serializable]
public class SeasonInProgressException : Exception
{
public SeasonInProgressException()
{
}

protected SeasonInProgressException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

public SeasonInProgressException(string msg) : base(msg)
{
}
Expand Down
12 changes: 12 additions & 0 deletions Lib9c/Action/Exceptions/EmptyRewardException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action.Exceptions
{
[Serializable]
public class EmptyRewardException : Exception
{
public EmptyRewardException()
{
}

public EmptyRewardException(string msg) : base(msg)
{
}

protected EmptyRewardException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
}

0 comments on commit 509cc5b

Please sign in to comment.