Added exception handler to loading config.
This commit is contained in:
parent
9c5bb75ac8
commit
780cb36f30
1 changed files with 15 additions and 5 deletions
|
|
@ -15,6 +15,7 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
|
||||||
|
|
@ -60,14 +61,23 @@ namespace TShockAPI
|
||||||
CreateIfNot(GroupsPath, Resources.groups);
|
CreateIfNot(GroupsPath, Resources.groups);
|
||||||
CreateIfNot(UsersPath, Resources.users);
|
CreateIfNot(UsersPath, Resources.users);
|
||||||
|
|
||||||
if (File.Exists(ConfigPath))
|
try
|
||||||
{
|
{
|
||||||
ConfigurationManager.ReadJsonConfiguration();
|
if (File.Exists(ConfigPath))
|
||||||
|
{
|
||||||
|
ConfigurationManager.ReadJsonConfiguration();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfigurationManager.WriteJsonConfiguration();
|
||||||
|
ConfigurationManager.ReadJsonConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ConfigurationManager.WriteJsonConfiguration();
|
Console.WriteLine("Error in config file");
|
||||||
ConfigurationManager.ReadJsonConfiguration();
|
Log.Error("Config Exception");
|
||||||
|
Log.Error(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Netplay.serverPort = ConfigurationManager.ServerPort;
|
Netplay.serverPort = ConfigurationManager.ServerPort;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue