|
|
@ -12,37 +12,35 @@ namespace Squidex.Infrastructure.States |
|
|
[Serializable] |
|
|
[Serializable] |
|
|
public class InconsistentStateException : Exception |
|
|
public class InconsistentStateException : Exception |
|
|
{ |
|
|
{ |
|
|
public long CurrentVersion { get; } |
|
|
public long VersionCurrent { get; } |
|
|
|
|
|
|
|
|
public long ExpectedVersion { get; } |
|
|
public long VersionExpected { get; } |
|
|
|
|
|
|
|
|
public InconsistentStateException(long currentVersion, long expectedVersion, Exception? inner = null) |
|
|
public InconsistentStateException(long current, long expected, Exception? inner = null) |
|
|
: base(FormatMessage(currentVersion, expectedVersion), inner) |
|
|
: base(FormatMessage(current, expected), inner) |
|
|
{ |
|
|
{ |
|
|
CurrentVersion = currentVersion; |
|
|
VersionCurrent = current; |
|
|
|
|
|
VersionExpected = expected; |
|
|
ExpectedVersion = expectedVersion; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected InconsistentStateException(SerializationInfo info, StreamingContext context) |
|
|
protected InconsistentStateException(SerializationInfo info, StreamingContext context) |
|
|
: base(info, context) |
|
|
: base(info, context) |
|
|
{ |
|
|
{ |
|
|
CurrentVersion = info.GetInt64(nameof(CurrentVersion)); |
|
|
VersionCurrent = info.GetInt64(nameof(VersionCurrent)); |
|
|
|
|
|
VersionExpected = info.GetInt64(nameof(VersionExpected)); |
|
|
ExpectedVersion = info.GetInt64(nameof(ExpectedVersion)); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void GetObjectData(SerializationInfo info, StreamingContext context) |
|
|
public override void GetObjectData(SerializationInfo info, StreamingContext context) |
|
|
{ |
|
|
{ |
|
|
info.AddValue(nameof(CurrentVersion), CurrentVersion); |
|
|
info.AddValue(nameof(VersionCurrent), VersionCurrent); |
|
|
info.AddValue(nameof(ExpectedVersion), ExpectedVersion); |
|
|
info.AddValue(nameof(VersionExpected), VersionExpected); |
|
|
|
|
|
|
|
|
base.GetObjectData(info, context); |
|
|
base.GetObjectData(info, context); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static string FormatMessage(long currentVersion, long expectedVersion) |
|
|
private static string FormatMessage(long current, long expected) |
|
|
{ |
|
|
{ |
|
|
return $"Requested version {expectedVersion}, but found {currentVersion}."; |
|
|
return $"Requested version {expected}, but found {current}."; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|