From b3668ba41d255ec7713ab31e9c8cc2f113ef0b7a Mon Sep 17 00:00:00 2001 From: "Jesse N. Glick" Date: Sat, 25 Feb 2006 00:50:48 +0000 Subject: [PATCH] More helpful diagnostic message for an obscure mistake I once made... git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@380876 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/ComponentHelper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java index dd8976f53..46fe1bbf4 100644 --- a/src/main/org/apache/tools/ant/ComponentHelper.java +++ b/src/main/org/apache/tools/ant/ComponentHelper.java @@ -496,10 +496,14 @@ public class ComponentHelper { if (c == null || !(Task.class.isAssignableFrom(c))) { return null; } - Task task = (Task) createComponent(taskType); - if (task == null) { + Object _task = createComponent(taskType); + if (_task == null) { return null; } + if (!(_task instanceof Task)) { + throw new BuildException("Expected a Task from '" + taskType + "' but got an instance of " + _task.getClass().getName() + " instead"); + } + Task task = (Task) _task; task.setTaskType(taskType); // set default value, can be changed by the user