mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
Refactored startup code, remove duplicate try-catches
This commit is contained in:
parent
fa15d5cb08
commit
0bf6e70214
28
source/app.d
28
source/app.d
@ -51,26 +51,19 @@ void main(string[] args)
|
||||
return;
|
||||
}
|
||||
|
||||
/* The JSON */
|
||||
JSONValue json;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
/* The JSON */
|
||||
JSONValue json;
|
||||
|
||||
/* Parse the configuration file */
|
||||
json = parseJSON(cast(string)data);
|
||||
}
|
||||
catch(JSONException e)
|
||||
{
|
||||
gprintln("Failure to parse configuration file'"~configFilename~"' with error:\n\n"~e.toString(), DebugType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a new configuration file and check configuration parameters */
|
||||
DGeneralConfig config = DGeneralConfig.getConfig(json["general"]);
|
||||
/* Create a new configuration file and check configuration parameters */
|
||||
DGeneralConfig config = DGeneralConfig.getConfig(json["general"]);
|
||||
|
||||
/* If the configuration reading was successful (valid JSON) */
|
||||
if(config)
|
||||
{
|
||||
/* Create a new server */
|
||||
DServer dserver = new DServer(config);
|
||||
|
||||
@ -90,12 +83,11 @@ void main(string[] args)
|
||||
|
||||
/* Start the server (TODO: This should start Meyer) */
|
||||
dserver.startServer();
|
||||
|
||||
}
|
||||
else
|
||||
catch(JSONException e)
|
||||
{
|
||||
gprintln("Failure to read a valid dnetd configuration file'"~configFilename~"'", DebugType.ERROR);
|
||||
gprintln("Failure to parse configuration file'"~configFilename~"' with error:\n\n"~e.toString(), DebugType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -12,7 +12,6 @@ import gogga;
|
||||
import dnetd.dlink : DLink;
|
||||
import dnetd.dserver : DServer;
|
||||
|
||||
|
||||
public final class DGeneralConfig
|
||||
{
|
||||
/* Addresses to bind sockets to */
|
||||
|
Loading…
Reference in New Issue
Block a user