From 3e31921e49e3d06ea55c51a497b157ad0f42ff8b Mon Sep 17 00:00:00 2001 From: Sameera Date: Tue, 18 Oct 2016 22:49:09 +0530 Subject: [PATCH] Removed try catch and set to throw the exception --- .../java/org/baeldung/corejava/Screenshot.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java b/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java index 57a754bb83..d33761932f 100644 --- a/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java +++ b/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java @@ -20,16 +20,12 @@ public class Screenshot { this.timeToWait = timeToWait; } - public void getScreenshot() { - try { - Thread.sleep(timeToWait); - Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); - Robot robot = new Robot(); - BufferedImage img = robot.createScreenCapture(rectangle); - ImageIO.write(img, fileType, setupFileNamePath()); - } catch (Exception ex) { - System.out.println("Error occurred while getting the Print Screen."); - } + public void getScreenshot() throws Exception { + Thread.sleep(timeToWait); + Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); + Robot robot = new Robot(); + BufferedImage img = robot.createScreenCapture(rectangle); + ImageIO.write(img, fileType, setupFileNamePath()); } private File setupFileNamePath() {