From ad3ccf027ec060e1adb3c9b6c577a8ebf32866b2 Mon Sep 17 00:00:00 2001 From: yankee Date: Fri, 18 Apr 2014 19:01:16 +0200 Subject: Prefer to throw an Error rather than returning a null value which _will_ eventually lead to a NullPointerException --- core/src/main/java/fi/iki/elonen/NanoHTTPD.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'core/src') diff --git a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java index 35690ed..ce709a7 100644 --- a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java +++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java @@ -1201,7 +1201,7 @@ public abstract class NanoHTTPD { dest.write(src.slice()); path = tempFile.getName(); } catch (Exception e) { // Catch exception if any - System.err.println("Error: " + e.getMessage()); + throw new Error(e); // we won't recover, so throw an error } finally { safeClose(fileOutputStream); } @@ -1214,9 +1214,8 @@ public abstract class NanoHTTPD { TempFile tempFile = tempFileManager.createTempFile(); return new RandomAccessFile(tempFile.getName(), "rw"); } catch (Exception e) { - System.err.println("Error: " + e.getMessage()); + throw new Error(e); // we won't recover, so throw an error } - return null; } /** -- cgit v1.2.3