1
0
mirror of https://github.com/CyberL1/MyMcRealms.git synced 2024-09-18 15:42:51 -04:00

feat: error handling

This commit is contained in:
CyberL1 2024-05-16 09:31:02 +02:00
parent d502f2d0f4
commit ec4a9c286b

View File

@ -15,15 +15,18 @@ namespace MyMcRealms.MyMcAPI
public async Task<AllServersResponse?> GetAllServers() public async Task<AllServersResponse?> GetAllServers()
{ {
AllServersResponse? response = await httpClient.GetFromJsonAsync<AllServersResponse>($"list_all_servers/{Environment.GetEnvironmentVariable("MYMC_SERVER_LIST_KEY")}"); try
{
if (response == null) AllServersResponse? response = await httpClient.GetFromJsonAsync<AllServersResponse>($"list_all_servers/{Environment.GetEnvironmentVariable("MYMC_SERVER_LIST_KEY")}");
return response;
}
catch (Exception e)
{ {
Console.WriteLine("error while doing GET /list_all_servers"); Console.WriteLine("error while doing GET /list_all_servers");
Console.WriteLine(e.Message);
return null; return null;
} }
return response;
} }
public HttpResponseMessage? ExecuteCommand(string command) public HttpResponseMessage? ExecuteCommand(string command)