summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1fa9243fa..b24ece4bd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -816,14 +816,22 @@ static bool run_dedicated_server(const GameParams &game_params, const Settings &
if (cmd_args.exists("migrate"))
return migrate_database(game_params, cmd_args);
- // Create server
- Server server(game_params.world_path, game_params.game_spec, false,
- bind_addr.isIPv6());
- server.start(bind_addr);
-
- // Run server
- bool &kill = *porting::signal_handler_killstatus();
- dedicated_server_loop(server, kill);
+ try {
+ // Create server
+ Server server(game_params.world_path, game_params.game_spec, false,
+ bind_addr.isIPv6());
+ server.start(bind_addr);
+
+ // Run server
+ bool &kill = *porting::signal_handler_killstatus();
+ dedicated_server_loop(server, kill);
+ } catch (const ModError &e) {
+ errorstream << "ModError: " << e.what() << std::endl;
+ return false;
+ } catch (const ServerError &e) {
+ errorstream << "ServerError: " << e.what() << std::endl;
+ return false;
+ }
return true;
}