Browse Source
Update exception message for missing object mapping
pull/23630/head
maliming
8 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
11 additions and
10 deletions
framework/src/Volo.Abp.Mapperly/Volo/Abp/Mapperly/MapperlyAutoObjectMappingProvider.cs
framework/test/Volo.Abp.Mapperly.Tests/Volo/Abp/Mapperly/AbpMapperlyModule_Basic_Tests.cs
@ -99,26 +99,26 @@ public class MapperlyAutoObjectMappingProvider : IAutoObjectMappingProvider
protected virtual AbpException GetNoMapperFoundException < TSource , TDestination > ( )
{
var newLine = Environment . NewLine ;
var message = "No type mapper class was found for the given source and destination types." +
var message = "No object mapping was found for the specified source and destination types." +
newLine +
newLine +
"Mapping types :" +
"Mapping attempted :" +
newLine +
$"{typeof(TSource).Name} -> {typeof(TDestination).Name}" +
newLine +
$"{typeof(TSource).FullName} -> {typeof(TDestination).FullName}" +
newLine +
newLine +
"Define a mapping class to resolve this issue:" +
"How to fix:" +
newLine +
"Define a mapping class for these types:" +
newLine +
" - Use MapperBase<TSource, TDestination> for one-way mapping." +
newLine +
" - Use TwoWayMapperBase<TDestination, TSource> for two-way mapping." +
newLine +
newLine +
"See the Mapperly documentation for details:" +
newLine +
"https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration" ;
"For details, see the Mapperly integration document https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration" ;
return new AbpException ( message ) ;
}
@ -106,13 +106,14 @@ public class AbpMapperlyModule_Basic_Tests : AbpIntegratedTest<MapperlyTestModul
public void Should_Throw_Exception_If_Mapper_Is_Not_Found ( )
{
var exception = Assert . Throws < AbpException > ( ( ) = > _ objectMapper . Map < MyEntity , MyClassDto > ( new MyEntity ( ) ) ) ;
exception . Message . ShouldBe ( "No type mapper class was found for the given source and destination types.\n\n" +
"Mapping types :\n" +
exception . Message . ShouldBe ( "No object mapping was found for the specified source and destination types.\n\n" +
"Mapping attempted :\n" +
"MyEntity -> MyClassDto\n" +
"Volo.Abp.Mapperly.SampleClasses.MyEntity -> Volo.Abp.Mapperly.MyClassDto\n\n" +
"Define a mapping class to resolve this issue:\n" +
"How to fix:\n" +
"Define a mapping class for these types:" + "\n" +
" - Use MapperBase<TSource, TDestination> for one-way mapping.\n" +
" - Use TwoWayMapperBase<TDestination, TSource> for two-way mapping.\n\n" +
"See the Mapperly documentation for details:\n https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration" ) ;
"For details, see the Mapperly integration document https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration" ) ;
}
}