From 1ed2f314b1584e046c036a2382c775f9f91467a4 Mon Sep 17 00:00:00 2001 From: Pascal Rapicault Date: Sun, 22 Feb 2009 20:00:30 +0000 Subject: Propogate back the status and report build exception --- .../repository/tools/tasks/MirrorTask.java | 9 ++++---- .../repository/tools/tasks/TaskHelper.java | 27 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/TaskHelper.java (limited to 'bundles/org.eclipse.equinox.p2.repository.tools/src_ant') diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java index fd0477579..06699c1a5 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java @@ -28,13 +28,14 @@ public class MirrorTask extends AbstractRepositoryTask { application.initializeRepos(null); List ius = prepareIUs(); if (ius == null || ius.size() == 0) - throw new BuildException("Need to specify one or more IUs."); + throw new BuildException("Need to specify one or more IUs to mirror."); application.setSourceIUs(ius); IStatus result = application.run(null); - if (result.matches(IStatus.ERROR)) - throw new ProvisionException(result); + if (result.matches(IStatus.ERROR)) { + throw new BuildException(TaskHelper.statusToString(result, null).toString()); + } } catch (ProvisionException e) { - throw new BuildException("Error occurred while transforming repository.", e); + throw new BuildException(e); } } diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/TaskHelper.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/TaskHelper.java new file mode 100644 index 000000000..7ef184e7c --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/TaskHelper.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.tasks; + +import org.eclipse.core.runtime.IStatus; + +public class TaskHelper { + public static StringBuffer statusToString(IStatus status, StringBuffer b) { + IStatus[] nestedStatus = status.getChildren(); + if (b == null) + b = new StringBuffer(); + b.append(status.getMessage()); + for (int i = 0; i < nestedStatus.length; i++) { + b.append('\n'); + b.append(statusToString(nestedStatus[i], b)); + } + return b; + } +} -- cgit v1.2.3