Skip to content

Commit

Permalink
Improve enduser usage
Browse files Browse the repository at this point in the history
  • Loading branch information
svr333 committed Jan 14, 2021
1 parent 207d2ed commit b5e841a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Exceptions/ServersNotOnlineException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace GLR.Net.Exceptions
{
public class ServersLaunchingException : GLRException
{
public override string Message => $"Servers are still launching!";
}
}
8 changes: 4 additions & 4 deletions src/Exceptions/StatsNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace GLR.Net.Exceptions
{
public class StatsNotFoundException : Exception
{
public StatsNotFoundException(BasicProfile user)
public StatsNotFoundException(string id)
{
User = user;
UserId = id;
}

public BasicProfile User { get; set; }
public override string Message => $"User statistics for '{User.Username}' not found.";
public string UserId { get; set; }
public override string Message => $"User statistics for '{UserId}' not found.";
}
}
2 changes: 1 addition & 1 deletion src/GLR.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>2.8</Version>
<Version>2.9</Version>
<Authors>svr333</Authors>
<Company>Galaxy Life Reborn</Company>
<PackageId>GLR.Net</PackageId>
Expand Down
7 changes: 6 additions & 1 deletion src/GLRClientAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GLR.Net
{
public partial class GLRClient
{
private HttpClient _webClient = new HttpClient() { Timeout = TimeSpan.FromMilliseconds(500) };
private HttpClient _webClient = new HttpClient() { Timeout = TimeSpan.FromSeconds(1000) };

public async Task<User> GetUserAsync(string input)
{
Expand Down Expand Up @@ -39,6 +39,11 @@ public async Task<Statistics> GetStatisticsAsync(string id)
var response = await _webClient.GetAsync($"https://mariflash.galaxylifereborn.com/account/statistics?id={id}");
var statisticsJson = await response.Content.ReadAsStringAsync();

if (statisticsJson == "Not ready!")
throw new ServersLaunchingException();
else if (statisticsJson == "Error!")
throw new StatsNotFoundException(id);

return JsonConvert.DeserializeObject<Statistics>(statisticsJson);
}

Expand Down

0 comments on commit b5e841a

Please sign in to comment.