Skip to content

Commit

Permalink
Adicionado algumas Exceções.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian-Sknz committed Oct 7, 2020
1 parent 265e878 commit 69e13c2
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 68 deletions.
22 changes: 1 addition & 21 deletions src/main/java/me/skiincraft/api/paladins/Paladins.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Boolean get() {
HttpRequest request = HttpRequest.get(url);
String body = request.body();
json = body;
bool = checkResponse(body);
bool = accessUtils.checkResponse(body);
if (!bool) {
throw new RequestException(body, body);
}
Expand Down Expand Up @@ -168,25 +168,5 @@ public AccessUtils getAccessUtils() {
public List<Session> getSessions(){
return sessions;
}

private boolean checkResponse(String body) {
if (body.contains("Invalid Developer Id")) {
return false;
}

if (body.contains("Invalid session id")) {
return false;
}

if (body.contains("Exception while validating developer access.")) {
return false;
}

if (body.contains("Error while comparing Server and Client timestamp")) {
return false;
}

return !body.contains("Exception - Timestamp");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public synchronized void addChampion(Champions champion) {
public synchronized void addMatch(Match match) {
RuntimeMemoryImpl<Match> impl = (RuntimeMemoryImpl<Match>) matchMemory;
Match[] c = impl.item;
List<Match> cc = Arrays.asList(c);
List<Match> cc = new ArrayList<>(Arrays.asList(c));
cc.add(match);
// Remove the last element
cc.removeAll(cc.stream().filter(cham -> cham.getMatchId() == cham.getMatchId()).collect(Collectors.toList()));
Expand All @@ -70,7 +70,7 @@ public synchronized void addCard(Cards cards) {
}

Cards[] c = impl.item;
List<Cards> cc = Arrays.asList(c);
List<Cards> cc = new ArrayList<>(Arrays.asList(c));
// Remove the last element
cc.removeAll(
cc.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.skiincraft.api.paladins.exceptions;

public class ChampionException extends RuntimeException {

public ChampionException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package me.skiincraft.api.paladins.exceptions;

public class MatchException extends Exception {

/**
*
*/
private static final long serialVersionUID = -5758961246899999315L;
private String message;

public class MatchException extends RuntimeException {

public MatchException(String message) {
this.message = message;
}

@Override
public String getMessage() {
return message;
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
package me.skiincraft.api.paladins.exceptions;

public class PlayerException extends Exception {
public class PlayerException extends RuntimeException {


/**
*
*/
private static final long serialVersionUID = 1L;
private String message;


public PlayerException(String message) {
this.message = message;
}

@Override
public String getMessage() {
return message;
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package me.skiincraft.api.paladins.exceptions;

public class RequestException extends RuntimeException {

/**
*
*/
private static final long serialVersionUID = 1L;

private String requestMessage;




public RequestException(String message) {
super(message);
}

public RequestException(String message, String retMsg) {
super(message);
this.requestMessage = retMsg;
}



public String getRequestMessage() {
return requestMessage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.skiincraft.api.paladins.exceptions;

public class SearchException extends RuntimeException {

public SearchException(String message) {
super(message);
}

}
Loading

0 comments on commit 69e13c2

Please sign in to comment.