Unreachable catch block for IOException
Unreachable catch block for IOException. This exception is never thrown from the try statement body
what would be correct?
My console throws this:
java.io.IOException: Server returned HTTP response code: 403 for URL: http://maps.googleapis.com/maps/api/streetview?size=640x640&location=40.416702,%20-86.87529&fov=90&heading=235&pitch=10&sensor=false
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.URL.openStream(URL.java:1010)
at processing.core.PApplet.createInputRaw(Unknown Source)
at processing.core.PApplet.createInput(Unknown Source)
at processing.core.PApplet.loadBytes(Unknown Source)
at processing.core.PApplet.loadImage(Unknown Source)
at processing.core.PApplet.loadImage(Unknown Source)
at MyFirstClass.getStreetViewImage(MyFirstClass.java:147)
at MyFirstClass.loadStreetViewImages(MyFirstClass.java:562)
at MyFirstClass.setup(MyFirstClass.java:78)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run( Thread.java:680)
-
public PImage getStreetViewImage(float lat, float lon) {
int w = 640;
int h = 640;
int fov = 90;
int heading = 235;
int pitch = 10;
boolean sensor = false;
PImage img;
try {
img = loadImage("http://maps.googleapis.com/maps/api/streetview?size=" + w + "x" + h + "&location=" + lat + ",%20" + lon + "&fov=" + fov + "&heading=" + heading + "&pitch=" + pitch + "&sensor=" + sensor, "jpg");
} catch(IOException e) {
return null;
}
return img;
}
I know i could check for null but then my console keeps giving the errors, and i'm expecting a lot of nulls then.
(due a query limit).