From 6b28c161e9da4afa2142488a065caea19f6ef0ac Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Tue, 28 Jan 2014 22:13:05 +0100 Subject: [PATCH] #112 Raising descriptive exception in case a type couldn't be loaded by name --- .../java/org/mapstruct/ap/model/common/TypeFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/processor/src/main/java/org/mapstruct/ap/model/common/TypeFactory.java b/processor/src/main/java/org/mapstruct/ap/model/common/TypeFactory.java index fd2179a2a..47f1209ff 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/common/TypeFactory.java +++ b/processor/src/main/java/org/mapstruct/ap/model/common/TypeFactory.java @@ -35,7 +35,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; - import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -96,6 +95,13 @@ public class TypeFactory { public Type getType(String canonicalName) { TypeElement typeElement = elementUtils.getTypeElement( canonicalName ); + + if ( typeElement == null ) { + throw new AnnotationProcessingException( + "Couldn't find type " + canonicalName + ". Are you missing a dependency on your classpath?" + ); + } + return getType( typeElement ); }