Browse Source

Serializable.

pull/169/head
Sebastian Stehle 9 years ago
parent
commit
b64939c47f
  1. 7
      src/Squidex.Infrastructure/Assets/AssetNotFoundException.cs
  2. 6
      src/Squidex.Infrastructure/CQRS/Events/WrongEventVersionException.cs
  3. 9
      src/Squidex.Infrastructure/ConfigurationException.cs
  4. 7
      src/Squidex.Infrastructure/DomainException.cs
  5. 7
      src/Squidex.Infrastructure/DomainForbiddenException.cs
  6. 7
      src/Squidex.Infrastructure/DomainObjectDeletedException.cs
  7. 7
      src/Squidex.Infrastructure/DomainObjectException.cs
  8. 7
      src/Squidex.Infrastructure/DomainObjectNotFoundException.cs
  9. 8
      src/Squidex.Infrastructure/DomainObjectVersionException.cs
  10. 38
      src/Squidex.Infrastructure/Orleans/OrleansException.cs
  11. 7
      src/Squidex.Infrastructure/TypeNameNotFoundException.cs
  12. 7
      src/Squidex.Infrastructure/ValidationException.cs

7
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)
{
}
}
}

6
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}.";

9
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)
{
}
}
}

7
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)
{
}
}
}

7
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)
{
}
}
}

7
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.";

7
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)
{
}
}
}

7
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.";

8
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}.";

38
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)
{
}
}
}

7
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)
{
}
}
}

7
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<ValidationError> FallbackErrors = new List<ValidationError>();
@ -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)));

Loading…
Cancel
Save