Skip to content

Commit

Permalink
Prefer to throw an Error rather than returning a null value which _wi…
Browse files Browse the repository at this point in the history
…ll_ eventually lead to a NullPointerException
  • Loading branch information
yankee42 committed Apr 18, 2014
1 parent 8523184 commit ad3ccf0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/fi/iki/elonen/NanoHTTPD.java
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ private String saveTmpFile(ByteBuffer b, int offset, int len) {
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);
}
Expand All @@ -1214,9 +1214,8 @@ private RandomAccessFile getTmpBucket() {
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;
}

/**
Expand Down

0 comments on commit ad3ccf0

Please sign in to comment.