fix: better error logging and validation in weapon selector

- Add debug logging for skipped weapons
- Handle empty strings and 'null' values
- Verify all files use correct API attribute names
This commit is contained in:
LemonNexus 2026-02-09 22:01:02 +00:00
parent d8b6ef998d
commit f6ec57d2a2
1 changed files with 10 additions and 1 deletions

View File

@ -113,13 +113,22 @@ class WeaponSelectorDialog(QDialog):
try:
# Validate that decay and ammo are valid numbers
decay_val = w.decay if w.decay is not None else 0
# NexusWeapon uses ammo_burn, not ammo
ammo_val = w.ammo_burn if w.ammo_burn is not None else 0
# Additional validation - skip if values are empty strings or 'null'
if decay_val == '' or decay_val == 'null':
decay_val = 0
if ammo_val == '' or ammo_val == 'null':
ammo_val = 0
# Try to convert to Decimal to validate
Decimal(str(decay_val))
Decimal(str(ammo_val))
self._weapons.append(w)
except (InvalidOperation, ValueError, TypeError):
except (InvalidOperation, ValueError, TypeError) as e:
# Skip weapons with invalid data
logger.debug(f"Skipping weapon {getattr(w, 'name', 'unknown')} due to invalid decay/ammo: {e}")
continue
# Sort by name