Actually handle errors instead of ignoring them

This commit is contained in:
2026-01-24 22:44:03 +01:00
parent 38e07aef1f
commit aa71fd73af

View File

@@ -275,13 +275,16 @@ func flattenVictim(ctx context.Context, db DB, victim Victim, flat *FlatKillmail
flat.VictimShipTypeID = int32(victim.ShipTypeID)
flat.VictimDamageTaken = victim.DamageTaken
g, _ := errgroup.WithContext(ctx)
g, ctx := errgroup.WithContext(ctx)
if victim.CharacterID != 0 {
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching character name for ID %d", victim.CharacterID)
name, _ := getCharacterName(victim.CharacterID)
name, err := getCharacterName(victim.CharacterID)
if err != nil {
flog.Debug("Character name fetch failed, using 'unknown'")
}
flat.VictimCharacterName = name
if name != "" && name != "unknown" {
flog.Debug("Got character name: %s (took %v)", name, time.Since(start))
@@ -296,7 +299,10 @@ func flattenVictim(ctx context.Context, db DB, victim Victim, flat *FlatKillmail
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching corporation name for ID %d", victim.CorporationID)
name, _ := getCorporationName(victim.CorporationID)
name, err := getCorporationName(victim.CorporationID)
if err != nil {
flog.Debug("Corporation name fetch failed, using 'unknown'")
}
flat.VictimCorporationName = name
if name != "" && name != "unknown" {
flog.Debug("Got corporation name: %s (took %v)", name, time.Since(start))
@@ -311,7 +317,10 @@ func flattenVictim(ctx context.Context, db DB, victim Victim, flat *FlatKillmail
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching alliance name for ID %d", victim.AllianceID)
name, _ := getAllianceName(victim.AllianceID)
name, err := getAllianceName(victim.AllianceID)
if err != nil {
flog.Debug("Alliance name fetch failed, using 'unknown'")
}
flat.VictimAllianceName = name
if name != "" && name != "unknown" {
flog.Debug("Got alliance name: %s (took %v)", name, time.Since(start))
@@ -385,13 +394,16 @@ func flattenAttacker(ctx context.Context, db DB, killmailID int64, attacker Atta
flat.AllianceID = &attacker.AllianceID
}
g, _ := errgroup.WithContext(ctx)
g, ctx := errgroup.WithContext(ctx)
if attacker.CharacterID != 0 {
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching character name")
name, _ := getCharacterName(attacker.CharacterID)
name, err := getCharacterName(attacker.CharacterID)
if err != nil {
flog.Debug("Character name fetch failed, using 'unknown'")
}
flat.CharacterName = name
if name != "" && name != "unknown" {
flog.Debug("Got character name: %s (took %v)", name, time.Since(start))
@@ -406,7 +418,10 @@ func flattenAttacker(ctx context.Context, db DB, killmailID int64, attacker Atta
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching corporation name")
name, _ := getCorporationName(attacker.CorporationID)
name, err := getCorporationName(attacker.CorporationID)
if err != nil {
flog.Debug("Corporation name fetch failed, using 'unknown'")
}
flat.CorporationName = name
if name != "" && name != "unknown" {
flog.Debug("Got corporation name: %s (took %v)", name, time.Since(start))
@@ -421,7 +436,10 @@ func flattenAttacker(ctx context.Context, db DB, killmailID int64, attacker Atta
g.Go(func() error {
start := time.Now()
flog.Debug("Fetching alliance name")
name, _ := getAllianceName(attacker.AllianceID)
name, err := getAllianceName(attacker.AllianceID)
if err != nil {
flog.Debug("Alliance name fetch failed, using 'unknown'")
}
flat.AllianceName = name
if name != "" && name != "unknown" {
flog.Debug("Got alliance name: %s (took %v)", name, time.Since(start))
@@ -491,7 +509,7 @@ func flattenItemType(ctx context.Context, db DB, killmailID int64, item Item) (*
Singleton: int32(item.Singleton),
}
g, _ := errgroup.WithContext(ctx)
g, ctx := errgroup.WithContext(ctx)
g.Go(func() error {
start := time.Now()
@@ -654,7 +672,7 @@ func getName[T namedEntity](entityType, cachePrefix string, entityID int64) (str
entity, err := cyutils.RequestCached[T](req, cacheFile)
if err != nil {
flog.Debug("%s request failed: %v", entityType, err)
return "unknown", nil
return "unknown", err
}
flog.Debug("Successfully got %s name: %s", entityType, entity.GetName())