Merge branch 'sentry2019Breadcrumbs' into 'master'

Sentry: add more Breadcumbs

See merge request core-developers/forge!1274
This commit is contained in:
Michael Kamensky
2019-01-13 09:44:15 +00:00
3 changed files with 256 additions and 233 deletions

View File

@@ -28,6 +28,8 @@ import forge.game.cost.Cost;
import forge.game.spellability.*;
import forge.game.zone.ZoneType;
import forge.util.FileSection;
import io.sentry.Sentry;
import io.sentry.event.BreadcrumbBuilder;
import java.util.List;
import java.util.Map;
@@ -130,7 +132,16 @@ public final class AbilityFactory {
String source = state.getName().isEmpty() ? abString : state.getName();
throw new RuntimeException("AbilityFactory : getAbility -- no API in " + source + ": " + abString);
}
try {
return getAbility(mapParams, type, state, parent);
} catch (Error | Exception ex) {
String msg = "AbilityFactory:getAbility: crash when trying to create ability ";
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage(msg)
.withData("Card", state.getName()).withData("Ability", abString).build()
);
throw new RuntimeException(msg + " of card: " + state.getName(), ex);
}
}
public static final SpellAbility getAbility(final Card hostCard, final String svar) {

View File

@@ -1447,6 +1447,7 @@ public class Card extends GameEntity implements Comparable<Card> {
int i = 0;
for (KeywordInterface inst : keywords) {
String keyword = inst.getOriginal();
try {
if (keyword.startsWith("SpellCantTarget")) {
continue;
}
@@ -1691,6 +1692,15 @@ public class Card extends GameEntity implements Comparable<Card> {
}
i++;
} catch (Exception e) {
String msg = "Card:keywordToText: crash in Keyword parsing";
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage(msg)
.withData("Card", this.getName()).withData("Keyword", keyword).build()
);
throw new RuntimeException("Error in Card " + this.getName() + " with Keyword " + keyword, e);
}
}
if (sb.length() > 0) {
sb.append("\r\n");

View File

@@ -430,6 +430,9 @@ public class CardFactory {
private static void readCardFace(Card c, ICardFace face) {
// Name first so Senty has the Card name
c.setName(face.getName());
for (String r : face.getReplacements()) c.addReplacementEffect(ReplacementHandler.parseReplacement(r, c, true));
for (String s : face.getStaticAbilities()) c.addStaticAbility(s);
for (String t : face.getTriggers()) c.addTrigger(TriggerHandler.parseTrigger(t, c, true));
@@ -439,7 +442,6 @@ public class CardFactory {
// keywords not before variables
c.addIntrinsicKeywords(face.getKeywords(), false);
c.setName(face.getName());
c.setManaCost(face.getManaCost());
c.setText(face.getNonAbilityText());