#30: add `IocContainerException` base exception:

- all exceptions inherit this base class
- allows handling of exceptions outside of the LightweightIocContainer
pull/37/head
Simon Gockner 6 years ago
parent 0ff27b114b
commit da1106e77f
  1. 2
      LightweightIocContainer/Exceptions/CircularDependencyException.cs
  2. 2
      LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs
  3. 3
      LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs
  4. 3
      LightweightIocContainer/Exceptions/InternalResolveException.cs
  5. 4
      LightweightIocContainer/Exceptions/InvalidRegistrationException.cs
  6. 54
      LightweightIocContainer/Exceptions/IocContainerException.cs
  7. 2
      LightweightIocContainer/Exceptions/MultipleRegistrationException.cs
  8. 14
      LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs
  9. 2
      LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs
  10. 2
      LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs
  11. 3
      LightweightIocContainer/Exceptions/UnknownRegistrationException.cs
  12. 35
      LightweightIocContainer/LightweightIocContainer.xml

@ -12,7 +12,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// A circular dependency was detected during <see cref="IIocContainer.Resolve{T}()"/>
/// </summary>
internal class CircularDependencyException : Exception
internal class CircularDependencyException : IocContainerException
{
/// <summary>
/// A circular dependency was detected during <see cref="IIocContainer.Resolve{T}()"/>

@ -10,7 +10,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// The constructor does not match the given or resolvable arguments
/// </summary>
internal class ConstructorNotMatchingException : Exception
internal class ConstructorNotMatchingException : IocContainerException
{
/// <summary>
/// The constructor does not match the given or resolvable arguments

@ -2,7 +2,6 @@
// Created: 2019-06-28
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using System.Reflection;
namespace LightweightIocContainer.Exceptions
@ -10,7 +9,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// The creation of the abstract method is illegal in its current state
/// </summary>
internal class IllegalAbstractMethodCreationException : Exception
internal class IllegalAbstractMethodCreationException : IocContainerException
{
/// <summary>
/// The creation of the abstract method is illegal in its current state

@ -2,7 +2,6 @@
// Created: 2019-05-27
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces;
namespace LightweightIocContainer.Exceptions
@ -10,7 +9,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance
/// </summary>
internal class InternalResolveException : Exception
internal class InternalResolveException : IocContainerException
{
/// <summary>
/// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance

@ -2,14 +2,12 @@
// Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
namespace LightweightIocContainer.Exceptions
{
/// <summary>
/// The registration is not valid
/// </summary>
internal class InvalidRegistrationException : Exception
internal class InvalidRegistrationException : IocContainerException
{
/// <summary>
/// The registration is not valid

@ -0,0 +1,54 @@
// Author: Gockner, Simon
// Created: 2019-11-22
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
namespace LightweightIocContainer.Exceptions
{
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
public abstract class IocContainerException : Exception
{
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
protected IocContainerException()
{
}
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
/// <param name="message">The message of the <see cref="Exception"/></param>
protected IocContainerException(string message)
: base(message)
{
}
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
/// <param name="message">The message of the <see cref="Exception"/></param>
/// <param name="innerException">The inner <see cref="Exception"/></param>
protected IocContainerException(string message, Exception innerException)
: base(message, innerException)
{
InnerExceptions = new List<Exception>()
{
innerException
};
}
/// <summary>
/// The inner exceptions of the <see cref="IocContainerException"/>
/// </summary>
[UsedImplicitly]
public List<Exception> InnerExceptions { get; protected set; }
}
}

@ -10,7 +10,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// The <see cref="System.Type"/> is already registered in this <see cref="IIocContainer"/>
/// </summary>
internal class MultipleRegistrationException : Exception
internal class MultipleRegistrationException : IocContainerException
{
/// <summary>
/// The <see cref="System.Type"/> is already registered in this <see cref="IIocContainer"/>

@ -11,7 +11,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// No matching constructor was found for the given or resolvable arguments
/// </summary>
internal class NoMatchingConstructorFoundException : AggregateException
internal class NoMatchingConstructorFoundException : IocContainerException
{
/// <summary>
/// No matching constructor was found for the given or resolvable arguments
@ -24,9 +24,9 @@ namespace LightweightIocContainer.Exceptions
Type = type;
if (exceptions == null)
InnerExceptions = new List<ConstructorNotMatchingException>();
InnerExceptions = new List<Exception>();
else
InnerExceptions = exceptions.ToList();
InnerExceptions = exceptions.OfType<Exception>().ToList();
}
@ -36,13 +36,7 @@ namespace LightweightIocContainer.Exceptions
public Type Type { get; }
/// <summary>
/// The inner exceptions of the <see cref="NoMatchingConstructorFoundException"/>
/// </summary>
public new List<ConstructorNotMatchingException> InnerExceptions { get; }
/// <summary>
/// Add an inner exception to the <see cref="InnerExceptions"/>
/// Add an inner exception to the <see cref="IocContainerException.InnerExceptions"/>
/// </summary>
/// <param name="exception">The <see cref="ConstructorNotMatchingException"/></param>
public void AddInnerException(ConstructorNotMatchingException exception)

@ -9,7 +9,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// No public constructor can be found for a <see cref="Type"/>
/// </summary>
internal class NoPublicConstructorFoundException : Exception
internal class NoPublicConstructorFoundException : IocContainerException
{
/// <summary>
/// No public constructor can be found for a <see cref="Type"/>

@ -10,7 +10,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/>
/// </summary>
internal class TypeNotRegisteredException : Exception
internal class TypeNotRegisteredException : IocContainerException
{
/// <summary>
/// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/>

@ -2,7 +2,6 @@
// Created: 2019-05-21
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Exceptions
@ -10,7 +9,7 @@ namespace LightweightIocContainer.Exceptions
/// <summary>
/// An unknown <see cref="IRegistration"/> was used
/// </summary>
internal class UnknownRegistrationException : Exception
internal class UnknownRegistrationException : IocContainerException
{
/// <summary>
/// An unknown <see cref="IRegistration"/> was used

@ -127,6 +127,34 @@
</summary>
<param name="message">The exception message</param>
</member>
<member name="T:LightweightIocContainer.Exceptions.IocContainerException">
<summary>
A base <see cref="T:System.Exception"/> for the <see cref="N:LightweightIocContainer"/>
</summary>
</member>
<member name="M:LightweightIocContainer.Exceptions.IocContainerException.#ctor">
<summary>
A base <see cref="T:System.Exception"/> for the <see cref="N:LightweightIocContainer"/>
</summary>
</member>
<member name="M:LightweightIocContainer.Exceptions.IocContainerException.#ctor(System.String)">
<summary>
A base <see cref="T:System.Exception"/> for the <see cref="N:LightweightIocContainer"/>
</summary>
<param name="message">The message of the <see cref="T:System.Exception"/></param>
</member>
<member name="M:LightweightIocContainer.Exceptions.IocContainerException.#ctor(System.String,System.Exception)">
<summary>
A base <see cref="T:System.Exception"/> for the <see cref="N:LightweightIocContainer"/>
</summary>
<param name="message">The message of the <see cref="T:System.Exception"/></param>
<param name="innerException">The inner <see cref="T:System.Exception"/></param>
</member>
<member name="P:LightweightIocContainer.Exceptions.IocContainerException.InnerExceptions">
<summary>
The inner exceptions of the <see cref="T:LightweightIocContainer.Exceptions.IocContainerException"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Exceptions.MultipleRegistrationException">
<summary>
The <see cref="T:System.Type"/> is already registered in this <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/>
@ -177,14 +205,9 @@
The <see cref="P:LightweightIocContainer.Exceptions.NoMatchingConstructorFoundException.Type"/> with no matching constructor
</summary>
</member>
<member name="P:LightweightIocContainer.Exceptions.NoMatchingConstructorFoundException.InnerExceptions">
<summary>
The inner exceptions of the <see cref="T:LightweightIocContainer.Exceptions.NoMatchingConstructorFoundException"/>
</summary>
</member>
<member name="M:LightweightIocContainer.Exceptions.NoMatchingConstructorFoundException.AddInnerException(LightweightIocContainer.Exceptions.ConstructorNotMatchingException)">
<summary>
Add an inner exception to the <see cref="P:LightweightIocContainer.Exceptions.NoMatchingConstructorFoundException.InnerExceptions"/>
Add an inner exception to the <see cref="P:LightweightIocContainer.Exceptions.IocContainerException.InnerExceptions"/>
</summary>
<param name="exception">The <see cref="T:LightweightIocContainer.Exceptions.ConstructorNotMatchingException"/></param>
</member>

Loading…
Cancel
Save