From 2608885d67a3a99406a8cf1bc660241c3574dcfa Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Tue, 5 May 2015 12:43:37 +0200 Subject: Bug 466249 - Propagate more exceptions to ease problem analysis We often get problem reports with stack traces that "end" somewhere in p2 even though it's obvious from looking at these places that there was a causing exception. These causing exceptions are often not propagated with the new exception that p2 creates and throws. I'm not sure if that's on purpose or just an oversight. I've prepared a proposal to enhance these places and make it easier to analyze the problems that users report. Change-Id: Iaa53448c53c18301113b42dbe80558eccec49e8e Signed-off-by: Eike Stepper --- .../src/org/eclipse/equinox/internal/p2/engine/ProfileLock.java | 6 +++--- .../eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'bundles/org.eclipse.equinox.p2.engine/src') diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileLock.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileLock.java index 70080ff80..11058450f 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileLock.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileLock.java @@ -43,11 +43,11 @@ public class ProfileLock { location.set(url, false, LOCK_FILENAME); return location; } catch (MalformedURLException e) { - throw new IllegalArgumentException(NLS.bind(Messages.SimpleProfileRegistry_Bad_profile_location, e.getLocalizedMessage())); + throw new IllegalArgumentException(NLS.bind(Messages.SimpleProfileRegistry_Bad_profile_location, e.getLocalizedMessage()), e); } catch (IllegalStateException e) { throw e; } catch (IOException e) { - throw new IllegalStateException(e.getLocalizedMessage()); + throw new IllegalStateException(e.getLocalizedMessage(), e); } } @@ -105,7 +105,7 @@ public class ProfileLock { lockHolder = current; } catch (IOException e) { - throw new IllegalStateException(NLS.bind(Messages.SimpleProfileRegistry_Profile_not_locked_due_to_exception, e.getLocalizedMessage())); + throw new IllegalStateException(NLS.bind(Messages.SimpleProfileRegistry_Profile_not_locked_due_to_exception, e.getLocalizedMessage()), e); } return true; } diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java index 2efe605c4..8c98a4c74 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java @@ -731,9 +731,13 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { xmlReader.parse(new InputSource(stream)); profileHandlers.put(profileHandler.getProfileId(), profileHandler); } catch (SAXException e) { - throw new IOException(e.getMessage()); + IOException ioException = new IOException(e.getMessage()); + ioException.initCause(e); + throw ioException; } catch (ParserConfigurationException e) { - throw new IOException(e.getMessage()); + IOException ioException = new IOException(e.getMessage()); + ioException.initCause(e); + throw ioException; } finally { stream.close(); } -- cgit v1.2.3