mirror of
https://github.com/UnlegitDqrk/Potato.git
synced 2025-10-02 06:30:15 +02:00
Add OvenException for oven related internal exceptions
This commit is contained in:
12
src/main/java/org/drtshock/OvenException.java
Normal file
12
src/main/java/org/drtshock/OvenException.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package org.drtshock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Joe Hirschfeld on 10/2/2015.
|
||||||
|
*/
|
||||||
|
public class OvenException extends Exception {
|
||||||
|
|
||||||
|
public OvenException(Exception internalException){
|
||||||
|
super(internalException);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -72,8 +72,9 @@ public class Potato implements Tuber {
|
|||||||
* Checks if the potato is put into the oven.
|
* Checks if the potato is put into the oven.
|
||||||
*
|
*
|
||||||
* @return true if potato is in the oven, false if otherwise
|
* @return true if potato is in the oven, false if otherwise
|
||||||
|
* @throws OvenException if the oven encounters an internal exception
|
||||||
*/
|
*/
|
||||||
public boolean isPutIntoOven() {
|
public boolean isPutIntoOven() throws OvenException {
|
||||||
try {
|
try {
|
||||||
final URL url = new URL("https://www.google.com/search?q=potato");
|
final URL url = new URL("https://www.google.com/search?q=potato");
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
@@ -82,8 +83,7 @@ public class Potato implements Tuber {
|
|||||||
int inOven = connection.getResponseCode();
|
int inOven = connection.getResponseCode();
|
||||||
return inOven == 200;
|
return inOven == 200;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
throw new OvenException(ex);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,11 @@ public class Potato implements Tuber {
|
|||||||
* @return true if this potato is baked, false if otherwise
|
* @return true if this potato is baked, false if otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isBaked() {
|
public boolean isBaked() {
|
||||||
|
try {
|
||||||
return this.isPutIntoOven();
|
return this.isPutIntoOven();
|
||||||
|
} catch (OvenException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user