Don’t throw exceptions when a single “return” would suffice.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 25 Mar 2011 23:35:13 +0000 (00:35 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 25 Mar 2011 23:35:13 +0000 (00:35 +0100)
src/main/java/net/pterodactylus/sone/web/UploadImagePage.java

index 17538a6..06afa8c 100644 (file)
@@ -70,7 +70,7 @@ public class UploadImagePage extends SoneTemplatePage {
                        String parentId = request.getHttpRequest().getPartAsStringFailsafe("parent", 36);
                        Album parent = webInterface.getCore().getAlbum(parentId, false);
                        if (parent == null) {
-                               throw new RedirectException("invalid.html");
+                               return;
                        }
                        String name = request.getHttpRequest().getPartAsStringFailsafe("title", 200);
                        String description = request.getHttpRequest().getPartAsStringFailsafe("description", 4000);
@@ -91,7 +91,7 @@ public class UploadImagePage extends SoneTemplatePage {
                                uploadedImage.flush();
                        } catch (IOException ioe1) {
                                logger.log(Level.WARNING, "Could not read uploaded image!", ioe1);
-                               throw new RedirectException("invalid.html");
+                               return;
                        } finally {
                                Closer.close(imageInputStream);
                                fileBucket.free();