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:
parent
d8b6ef998d
commit
f6ec57d2a2
|
|
@ -113,13 +113,22 @@ class WeaponSelectorDialog(QDialog):
|
||||||
try:
|
try:
|
||||||
# Validate that decay and ammo are valid numbers
|
# Validate that decay and ammo are valid numbers
|
||||||
decay_val = w.decay if w.decay is not None else 0
|
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
|
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
|
# Try to convert to Decimal to validate
|
||||||
Decimal(str(decay_val))
|
Decimal(str(decay_val))
|
||||||
Decimal(str(ammo_val))
|
Decimal(str(ammo_val))
|
||||||
self._weapons.append(w)
|
self._weapons.append(w)
|
||||||
except (InvalidOperation, ValueError, TypeError):
|
except (InvalidOperation, ValueError, TypeError) as e:
|
||||||
# Skip weapons with invalid data
|
# Skip weapons with invalid data
|
||||||
|
logger.debug(f"Skipping weapon {getattr(w, 'name', 'unknown')} due to invalid decay/ammo: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Sort by name
|
# Sort by name
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue