Skip to content

Commit a223480

Browse files
feat: Added internal server error handling
1 parent 6f19596 commit a223480

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

config.example.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ icon_path = "server_icon.png"
2525
success = "Hello, §6{{NAME}}§r! Your code is: §a{{CODE}}"
2626
bad_session = "§cFailed to login: Invalid session (Try restarting your game and the launcher)"
2727
using_proxy = "§cYou are using a proxy!"
28+
internal_error = "§cSorry, internal server error occurred"

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ icon_path = "server_icon.png"
2525
success = "Hello, §6{{NAME}}§r! Your code is: §a{{CODE}}"
2626
bad_session = "§cFailed to login: Invalid session (Try restarting your game and the launcher)"
2727
using_proxy = "§cYou are using a proxy!"
28+
internal_error = "§cSorry, internal server error occurred"

src/config/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,7 @@ pub struct Messages {
9494

9595
/// Using a proxy
9696
pub using_proxy: String,
97+
98+
/// Message for internal server error
99+
pub internal_error: String,
97100
}

src/server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ impl MinecraftServer {
7777
"Connection from {:?} closed successfully",
7878
self.session.addr
7979
),
80-
Err(e) => error!("Internal error occurred: {}", e),
80+
Err(e) => {
81+
let _ = self
82+
.send_disconnect(self.config.messages.internal_error.clone())
83+
.await;
84+
error!("Internal error occurred: {}", e)
85+
}
8186
}
8287
}
8388

0 commit comments

Comments
 (0)