Skip to content

Commit

Permalink
CODE RUB: Replaced the abstract classes with interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdutoit committed Feb 2, 2024
1 parent bb55d59 commit 671f7e8
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using STX.Serialization.Providers.Abstractions.Models.Exceptions;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Tests.Unit.Models.Exceptions
{
internal class TestDependencyException : SerializationDependencyExceptionBase
internal class TestDependencyException : Xeption, ISerializationDependencyException
{
public TestDependencyException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using STX.Serialization.Providers.Abstractions.Models.Exceptions;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Tests.Unit.Models.Exceptions
{
internal class TestDependencyValidationException : SerializationDependencyValidationExceptionBase
internal class TestDependencyValidationException : Xeption, ISerializationDependencyValidationException
{
public TestDependencyValidationException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using STX.Serialization.Providers.Abstractions.Models.Exceptions;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Tests.Unit.Models.Exceptions
{
internal class TestServiceException : SerializationServiceExceptionBase
internal class TestServiceException : Xeption, ISerializationServiceException
{
public TestServiceException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using STX.Serialization.Providers.Abstractions.Models.Exceptions;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Tests.Unit.Models.Exceptions
{
internal class TestValidationException : SerializationValidationExceptionBase
internal class TestValidationException : Xeption, ISerializationValidationException
{
public TestValidationException(string message, Xeption innerException)
: base(message, innerException)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public interface ISerializationDependencyException
{ }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public interface ISerializationDependencyValidationException
{ }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public interface ISerializationServiceException
{ }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public interface ISerializationValidationException
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// ----------------------------------------------------------------------------------

using System.Collections;
using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public class SerializationDependencyProviderException : SerializationDependencyExceptionBase
public class SerializationDependencyProviderException : Xeption
{
public SerializationDependencyProviderException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// ----------------------------------------------------------------------------------

using System.Collections;
using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public class SerializationServiceProviderException : SerializationServiceExceptionBase
public class SerializationServiceProviderException : Xeption
{
public SerializationServiceProviderException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// ----------------------------------------------------------------------------------

using System.Collections;
using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public class SerializationValidationProviderException : SerializationValidationExceptionBase
public class SerializationValidationProviderException : Xeption
{
public SerializationValidationProviderException(string message, Xeption innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace STX.Serialization.Providers.Abstractions.Models.Exceptions
{
public class UncatagorizedSerializationProviderException : Xeption
internal class UncatagorizedSerializationProviderException : Xeption
{
public UncatagorizedSerializationProviderException(string message, Exception innerException)
: base(message, innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Xeption" Version="2.6.0" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="STX.Serialization.Providers.Abstractions.Tests.Unit" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>

<ItemGroup>
<None Include="..\README.md">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Threading.Tasks;
using STX.Serialization.Providers.Abstractions.Models.Exceptions;
using STX.Serialization.Providers.Abstractions.Models.Exceptions.Bases;
using Xeptions;

namespace STX.Serialization.Providers.Abstractions
Expand All @@ -19,19 +18,19 @@ private async ValueTask<TOutput> TryCatch<TInput, TOutput>(
{
return await asyncFunction();
}
catch (Xeption ex) when (ex is SerializationValidationExceptionBase)
catch (Exception ex) when (ex is ISerializationValidationException)
{
throw CreateValidationException(ex);
}
catch (Xeption ex) when (ex is SerializationDependencyValidationExceptionBase)
catch (Exception ex) when (ex is ISerializationDependencyValidationException)
{
throw CreateValidationException(ex);
}
catch (Xeption ex) when (ex is SerializationDependencyExceptionBase)
catch (Exception ex) when (ex is ISerializationDependencyException)
{
throw CreateDependencyException(ex);
}
catch (Xeption ex) when (ex is SerializationServiceExceptionBase)
catch (Exception ex) when (ex is ISerializationServiceException)
{
throw CreateServiceException(ex);
}
Expand All @@ -49,34 +48,34 @@ private async ValueTask<TOutput> TryCatch<TInput, TOutput>(
}

private SerializationValidationProviderException CreateValidationException(
Xeption exception)
Exception exception)
{
var serializationValidationException =
new SerializationValidationProviderException(
message: "Serialization validation errors occurred, please try again.",
innerException: exception,
innerException: exception as Xeption,
data: exception.Data);

return serializationValidationException;
}

private SerializationDependencyProviderException CreateDependencyException(
Xeption exception)
Exception exception)
{
var serializationDependencyException = new SerializationDependencyProviderException(
message: "Serialization dependency error occurred, contact support.",
innerException: exception,
innerException: exception as Xeption,
data: exception.Data);

return serializationDependencyException;
}

private SerializationServiceProviderException CreateServiceException(
Xeption exception)
Exception exception)
{
var serializationServiceException = new SerializationServiceProviderException(
message: "Serialization service error occurred, contact support.",
innerException: exception,
innerException: exception as Xeption,
data: exception.Data);

return serializationServiceException;
Expand Down

0 comments on commit 671f7e8

Please sign in to comment.