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
32
source/app.d
32
source/app.d
@ -51,26 +51,19 @@ void main(string[] args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The JSON */
|
|
||||||
JSONValue json;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
/* The JSON */
|
||||||
|
JSONValue json;
|
||||||
|
|
||||||
/* Parse the configuration file */
|
/* Parse the configuration file */
|
||||||
json = parseJSON(cast(string)data);
|
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 */
|
/* Create a new configuration file and check configuration parameters */
|
||||||
DGeneralConfig config = DGeneralConfig.getConfig(json["general"]);
|
DGeneralConfig config = DGeneralConfig.getConfig(json["general"]);
|
||||||
|
|
||||||
/* If the configuration reading was successful (valid JSON) */
|
|
||||||
if(config)
|
|
||||||
{
|
|
||||||
/* Create a new server */
|
/* Create a new server */
|
||||||
DServer dserver = new DServer(config);
|
DServer dserver = new DServer(config);
|
||||||
|
|
||||||
@ -90,12 +83,11 @@ void main(string[] args)
|
|||||||
|
|
||||||
/* Start the server (TODO: This should start Meyer) */
|
/* Start the server (TODO: This should start Meyer) */
|
||||||
dserver.startServer();
|
dserver.startServer();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gprintln("Failure to read a valid dnetd configuration file'"~configFilename~"'", DebugType.ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(JSONException e)
|
||||||
|
{
|
||||||
|
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.dlink : DLink;
|
||||||
import dnetd.dserver : DServer;
|
import dnetd.dserver : DServer;
|
||||||
|
|
||||||
|
|
||||||
public final class DGeneralConfig
|
public final class DGeneralConfig
|
||||||
{
|
{
|
||||||
/* Addresses to bind sockets to */
|
/* Addresses to bind sockets to */
|
||||||
|
Loading…
Reference in New Issue
Block a user