From 9c853ad5d648e0e930e5910006cdd3ce119d2f55 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 23 Oct 2015 21:21:14 +0200 Subject: [PATCH] Make sure AbstractHttpExceptions have a meaningful toString(). --- .../pte/exception/AbstractHttpException.java | 12 +++++------- .../pte/exception/UnexpectedRedirectException.java | 8 +++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/enabler/src/de/schildbach/pte/exception/AbstractHttpException.java b/enabler/src/de/schildbach/pte/exception/AbstractHttpException.java index 08e7f078..73b28ce6 100644 --- a/enabler/src/de/schildbach/pte/exception/AbstractHttpException.java +++ b/enabler/src/de/schildbach/pte/exception/AbstractHttpException.java @@ -32,18 +32,16 @@ public abstract class AbstractHttpException extends IOException private final URL url; private final Reader errorReader; - public AbstractHttpException(final URL url, final Reader errorReader) + public AbstractHttpException(final URL url) { - super(); - this.url = url; - this.errorReader = errorReader; + this(url, null); } - public AbstractHttpException(final URL url, final String message) + public AbstractHttpException(final URL url, final Reader errorReader) { - super(message); + super(url.toString()); this.url = url; - this.errorReader = null; + this.errorReader = errorReader; } public URL getUrl() diff --git a/enabler/src/de/schildbach/pte/exception/UnexpectedRedirectException.java b/enabler/src/de/schildbach/pte/exception/UnexpectedRedirectException.java index 1b628a28..dcd9c1d7 100644 --- a/enabler/src/de/schildbach/pte/exception/UnexpectedRedirectException.java +++ b/enabler/src/de/schildbach/pte/exception/UnexpectedRedirectException.java @@ -29,7 +29,7 @@ public class UnexpectedRedirectException extends AbstractHttpException public UnexpectedRedirectException(final URL originalUrl, final URL redirectedUrl) { - super(originalUrl, originalUrl + " -> " + redirectedUrl); + super(originalUrl); this.redirectedUrl = redirectedUrl; } @@ -37,4 +37,10 @@ public class UnexpectedRedirectException extends AbstractHttpException { return redirectedUrl; } + + @Override + public String toString() + { + return getClass().getName() + ": " + getUrl() + " -> " + redirectedUrl; + } }