From 09bb9264301e72674a37df171976d7dbab374376 Mon Sep 17 00:00:00 2001 From: "Micael Levi L. Cavalcante" Date: Thu, 9 Mar 2023 22:48:18 -0400 Subject: [PATCH] feat(core): use model's name on mapping error message (#518) --- packages/core/src/lib/utils/get-mapping.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lib/utils/get-mapping.ts b/packages/core/src/lib/utils/get-mapping.ts index 25cfd239e..6e3f8cf49 100644 --- a/packages/core/src/lib/utils/get-mapping.ts +++ b/packages/core/src/lib/utils/get-mapping.ts @@ -23,10 +23,12 @@ export function getMapping( ?.get(destinationIdentifier); if (mapping == null && !allowNull) { + const sourceName = + typeof source === 'function' ? (source.name || String(source)) : String(source); + const destinationName = + typeof destination === 'function' ? (destination.name || String(destination)) : String(destination); const errorHandler = getErrorHandler(mapper); - const errorMessage = `Mapping is not found for ${String( - source - )} and ${String(destination)}`; + const errorMessage = `Mapping is not found for ${sourceName} and ${destinationName}`; errorHandler.handle(errorMessage); throw new Error(errorMessage); }