Return null instead of IllegalArgumentException from hiscore

- Return null instead of throwing IllegalArgumentException from hiscore
(this was how it worked before)
- Add null checks and for hiscoreClient

Fixes #5513

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-09-17 15:25:01 +02:00
parent 45cb0bcde7
commit ec014798ca
2 changed files with 33 additions and 1 deletions

View File

@@ -45,6 +45,12 @@ public class HiscoreClient
public HiscoreResult lookup(String username, HttpUrl endpoint) throws IOException
{
HiscoreResultBuilder resultBuilder = lookupUsername(username, endpoint);
if (resultBuilder == null)
{
return null;
}
return resultBuilder.build();
}
@@ -56,6 +62,12 @@ public class HiscoreClient
public SingleHiscoreSkillResult lookup(String username, HiscoreSkill skill, HiscoreEndpoint endpoint) throws IOException
{
HiscoreResultBuilder resultBuilder = lookupUsername(username, endpoint.getHiscoreURL());
if (resultBuilder == null)
{
return null;
}
HiscoreResult result = resultBuilder.build();
Skill requested = result.getSkill(skill);
@@ -92,7 +104,7 @@ public class HiscoreClient
switch (okresponse.code())
{
case 404:
throw new IllegalArgumentException();
return null;
default:
throw new IOException("Error retrieving data from Jagex Hiscores: " + okresponse.message());
}