|
@@ -156,6 +156,9 @@ class TokenDisplayFormatter:
|
|
|
"""
|
|
|
Format a price with appropriate decimal places.
|
|
|
"""
|
|
|
+ if price is None:
|
|
|
+ return "N/A" # Handle None price gracefully
|
|
|
+
|
|
|
try:
|
|
|
decimal_places = 2 # Default if no token
|
|
|
if token:
|
|
@@ -172,7 +175,12 @@ class TokenDisplayFormatter:
|
|
|
return f"{price:,.{decimal_places}f}"
|
|
|
except Exception as e:
|
|
|
logger.error(f"❌ Error formatting price {price} for {token}: {e}")
|
|
|
- return f"{price:,.2f}"
|
|
|
+ # Fallback for other errors, assuming price is not None here due to the check above
|
|
|
+ # If it could still be an issue, provide a very basic fallback.
|
|
|
+ try:
|
|
|
+ return f"{price:,.2f}"
|
|
|
+ except: # Final fallback if even basic formatting fails
|
|
|
+ return str(price) # Convert to string as last resort
|
|
|
|
|
|
def format_price_with_symbol(self, price: float, token: str = None) -> str:
|
|
|
"""
|