Question

There are two types of exceptions in Automapper and I can´t find information anywhere on how to use them.

The exceptions are AutoMapperMappingException and AutoMapperConfigurationException

Does anybody know the difference of these two and how I should set up try/catch for them?

Was it helpful?

Solution

Check the source code.

AutoMapperConfigurationException is used when the mapping profiles are loaded up by AutoMapper. Its thrown my Automapper when performing a configuration checks.

    [Test]
    public void Mapper_AssertConfigurationIsValid_Expect_No_Exceptions()
    {
        AutoMapper.Mapper.AssertConfigurationIsValid();
    }

AutoMapperMappingException is used during "runtime"...that is when the actual mapping code is run to turn your source dto to your destination dto.

HTH.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top