diff --git a/src/Squidex.Infrastructure/Assets/AssetNotFoundException.cs b/src/Squidex.Infrastructure/Assets/AssetNotFoundException.cs index 86a5a9f92..92e9009cc 100644 --- a/src/Squidex.Infrastructure/Assets/AssetNotFoundException.cs +++ b/src/Squidex.Infrastructure/Assets/AssetNotFoundException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure.Assets { + [Serializable] public class AssetNotFoundException : Exception { public AssetNotFoundException() @@ -25,5 +27,10 @@ namespace Squidex.Infrastructure.Assets : base(message, inner) { } + + protected AssetNotFoundException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/CQRS/Events/WrongEventVersionException.cs b/src/Squidex.Infrastructure/CQRS/Events/WrongEventVersionException.cs index 030197c3f..010e32dfe 100644 --- a/src/Squidex.Infrastructure/CQRS/Events/WrongEventVersionException.cs +++ b/src/Squidex.Infrastructure/CQRS/Events/WrongEventVersionException.cs @@ -7,6 +7,7 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure.CQRS.Events { @@ -33,6 +34,11 @@ namespace Squidex.Infrastructure.CQRS.Events this.expectedVersion = expectedVersion; } + protected WrongEventVersionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + private static string FormatMessage(long currentVersion, long expectedVersion) { return $"Requested version {expectedVersion}, but found {currentVersion}."; diff --git a/src/Squidex.Infrastructure/ConfigurationException.cs b/src/Squidex.Infrastructure/ConfigurationException.cs index ce116635d..158447040 100644 --- a/src/Squidex.Infrastructure/ConfigurationException.cs +++ b/src/Squidex.Infrastructure/ConfigurationException.cs @@ -7,10 +7,12 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { - public sealed class ConfigurationException : Exception + [Serializable] + public class ConfigurationException : Exception { public ConfigurationException() { @@ -25,5 +27,10 @@ namespace Squidex.Infrastructure : base(message, inner) { } + + protected ConfigurationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/DomainException.cs b/src/Squidex.Infrastructure/DomainException.cs index 6fa8f9be7..89e3767fa 100644 --- a/src/Squidex.Infrastructure/DomainException.cs +++ b/src/Squidex.Infrastructure/DomainException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class DomainException : Exception { public DomainException(string message) @@ -21,5 +23,10 @@ namespace Squidex.Infrastructure : base(message, inner) { } + + protected DomainException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/DomainForbiddenException.cs b/src/Squidex.Infrastructure/DomainForbiddenException.cs index 13a838583..49a45957e 100644 --- a/src/Squidex.Infrastructure/DomainForbiddenException.cs +++ b/src/Squidex.Infrastructure/DomainForbiddenException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class DomainForbiddenException : DomainException { public DomainForbiddenException(string message) @@ -21,5 +23,10 @@ namespace Squidex.Infrastructure : base(message, inner) { } + + protected DomainForbiddenException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/DomainObjectDeletedException.cs b/src/Squidex.Infrastructure/DomainObjectDeletedException.cs index 17d27bdf0..307d52d2b 100644 --- a/src/Squidex.Infrastructure/DomainObjectDeletedException.cs +++ b/src/Squidex.Infrastructure/DomainObjectDeletedException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class DomainObjectDeletedException : DomainObjectException { public DomainObjectDeletedException(string id, Type type) @@ -17,6 +19,11 @@ namespace Squidex.Infrastructure { } + protected DomainObjectDeletedException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + private static string FormatMessage(string id, Type type) { return $"Domain object \'{id}\' (type {type}) already deleted."; diff --git a/src/Squidex.Infrastructure/DomainObjectException.cs b/src/Squidex.Infrastructure/DomainObjectException.cs index bfa481488..cf5498093 100644 --- a/src/Squidex.Infrastructure/DomainObjectException.cs +++ b/src/Squidex.Infrastructure/DomainObjectException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class DomainObjectException : Exception { private readonly string id; @@ -32,5 +34,10 @@ namespace Squidex.Infrastructure typeName = type?.Name; } + + protected DomainObjectException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs b/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs index 65d3872d2..472259bf0 100644 --- a/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs +++ b/src/Squidex.Infrastructure/DomainObjectNotFoundException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class DomainObjectNotFoundException : DomainObjectException { public DomainObjectNotFoundException(string id, Type type) @@ -22,6 +24,11 @@ namespace Squidex.Infrastructure { } + protected DomainObjectNotFoundException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + private static string FormatMessage(string id, Type type) { return $"Domain object \'{id}\' (type {type}) is not found."; diff --git a/src/Squidex.Infrastructure/DomainObjectVersionException.cs b/src/Squidex.Infrastructure/DomainObjectVersionException.cs index 19599594d..7408f52fe 100644 --- a/src/Squidex.Infrastructure/DomainObjectVersionException.cs +++ b/src/Squidex.Infrastructure/DomainObjectVersionException.cs @@ -10,7 +10,8 @@ using System; namespace Squidex.Infrastructure { - public class DomainObjectVersionException : DomainObjectException + [Serializable] + public sealed class DomainObjectVersionException : DomainObjectException { private readonly long currentVersion; private readonly long expectedVersion; @@ -33,6 +34,11 @@ namespace Squidex.Infrastructure this.expectedVersion = expectedVersion; } + protected DomainObjectVersionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + private static string FormatMessage(string id, Type type, long currentVersion, long expectedVersion) { return $"Requested version {expectedVersion} for object '{id}' (type {type}), but found {currentVersion}."; diff --git a/src/Squidex.Infrastructure/Orleans/OrleansException.cs b/src/Squidex.Infrastructure/Orleans/OrleansException.cs new file mode 100644 index 000000000..d54b3d399 --- /dev/null +++ b/src/Squidex.Infrastructure/Orleans/OrleansException.cs @@ -0,0 +1,38 @@ +// ========================================================================== +// OrleansException.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +using System; +using System.Runtime.Serialization; + +namespace Squidex.Infrastructure.Orleans +{ + [Serializable] + public class OrleansException : Exception + { + public OrleansException() + { + } + + public OrleansException(string message) + : base(message) + { + } + + public OrleansException(string message, Exception inner) + : base(message, inner) + { + } + + protected OrleansException( + SerializationInfo info, + StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/Squidex.Infrastructure/TypeNameNotFoundException.cs b/src/Squidex.Infrastructure/TypeNameNotFoundException.cs index 35c5db9ff..520351477 100644 --- a/src/Squidex.Infrastructure/TypeNameNotFoundException.cs +++ b/src/Squidex.Infrastructure/TypeNameNotFoundException.cs @@ -7,9 +7,11 @@ // ========================================================================== using System; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class TypeNameNotFoundException : Exception { public TypeNameNotFoundException() @@ -25,5 +27,10 @@ namespace Squidex.Infrastructure : base(message, inner) { } + + protected TypeNameNotFoundException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Squidex.Infrastructure/ValidationException.cs b/src/Squidex.Infrastructure/ValidationException.cs index 637021487..71034ed5b 100644 --- a/src/Squidex.Infrastructure/ValidationException.cs +++ b/src/Squidex.Infrastructure/ValidationException.cs @@ -9,9 +9,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace Squidex.Infrastructure { + [Serializable] public class ValidationException : Exception { private static readonly List FallbackErrors = new List(); @@ -46,6 +48,11 @@ namespace Squidex.Infrastructure this.errors = errors ?? FallbackErrors; } + protected ValidationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + public override string ToString() { return string.Join(" ", Enumerable.Repeat(Message, 1).Union(Errors.Select(x => x.Message)));