mirror of
https://github.com/JonasunderscoreJones/McWebserver.git
synced 2025-10-22 19:09:19 +02:00
Added error message on 404 page missing
This commit is contained in:
parent
cc6152f471
commit
236f62c141
1 changed files with 4 additions and 0 deletions
|
@ -25,6 +25,7 @@ import java.nio.file.NoSuchFileException;
|
|||
import java.nio.file.Path;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import static me.jonasjones.mcwebserver.web.ServerHandler.mcserveractive;
|
||||
|
@ -379,6 +380,9 @@ public class HttpServer implements Runnable {
|
|||
VerboseLogger.error("File " + fileRequested + " not found");
|
||||
} catch (Exception e) {
|
||||
VerboseLogger.error("Error with file not found exception : " + e.getMessage());
|
||||
if (Objects.equals(e.getMessage(), WEB_ROOT.resolve(FILE_NOT_FOUND).toString())) {
|
||||
VerboseLogger.error("Couldn't find fallback 404 file. Sending JSON 404 error.");
|
||||
}
|
||||
dataOut.write("HTTP/1.1 404 Not Found\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
dataOut.write("Date: %s\r\n".formatted(Instant.now()).getBytes(StandardCharsets.UTF_8));
|
||||
dataOut.write("Content-Type: application/json\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue