Use our own exception type for HTTP_NOT_FOUND, rather than reusing FileNotFoundException.

This commit is contained in:
Andreas Schildbach 2014-07-13 13:52:11 +02:00
parent 0999b3ba7f
commit bff85b9f6c
3 changed files with 34 additions and 8 deletions

View file

@ -17,7 +17,6 @@
package de.schildbach.pte;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
@ -70,7 +69,6 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.Trip;
import de.schildbach.pte.exception.InvalidDataException;
import de.schildbach.pte.exception.ParserException;
import de.schildbach.pte.exception.SessionExpiredException;
import de.schildbach.pte.util.ParserUtils;
import de.schildbach.pte.util.XmlPullUtil;
@ -2256,10 +2254,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
{
throw new ParserException("cannot parse xml: " + firstChars, x);
}
catch (final FileNotFoundException x)
{
throw new SessionExpiredException();
}
catch (final RuntimeException x)
{
throw new RuntimeException("uncategorized problem while processing " + uri, x);

View file

@ -0,0 +1,32 @@
/*
* Copyright 2014 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.exception;
import java.io.Reader;
import java.net.URL;
/**
* @author Andreas Schildbach
*/
public class NotFoundException extends AbstractHttpException
{
public NotFoundException(final URL url, final Reader errorReader)
{
super(url, errorReader);
}
}

View file

@ -18,7 +18,6 @@
package de.schildbach.pte.util;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -42,6 +41,7 @@ import java.util.zip.GZIPInputStream;
import de.schildbach.pte.exception.BlockedException;
import de.schildbach.pte.exception.InternalErrorException;
import de.schildbach.pte.exception.NotFoundException;
import de.schildbach.pte.exception.SessionExpiredException;
import de.schildbach.pte.exception.UnexpectedRedirectException;
@ -197,7 +197,7 @@ public final class ParserUtils
}
else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND)
{
throw new FileNotFoundException(url.toString());
throw new NotFoundException(url, new InputStreamReader(connection.getErrorStream(), requestEncoding));
}
else if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP)
{