Skip to content

wp#11

Merged
1batu merged 2 commits intoDigitalCoreHub:mainfrom
1batu:main
Nov 9, 2025
Merged

wp#11
1batu merged 2 commits intoDigitalCoreHub:mainfrom
1batu:main

Conversation

@1batu
Copy link
Member

@1batu 1batu commented Nov 9, 2025

This pull request focuses on improving error handling and code robustness throughout the codebase, particularly in database operations and resource management. The main changes ensure that errors are properly checked and handled, default values are set on failure, and resource cleanup is performed safely.

Error handling and robustness improvements:

  • Added error checks for all database queries in metrics_handler.go and set default values if queries fail, preventing potential panics and ensuring Prometheus metrics are always returned with valid values. [1] [2]
  • Added error handling for the main query in GetActiveStocks in universe_handler.go, setting zero values on failure to avoid returning incomplete or nil data.
  • Wrapped the universe update trigger in a goroutine with error logging to prevent unhandled errors from affecting the response.
  • Updated transaction rollback in trading_engine.go to safely ignore rollback errors if the transaction was already committed, preventing misleading error logs.

Resource and API usage improvements:

  • Used blank identifier (_ = ...) for function calls where errors are intentionally ignored, such as setting deadlines and limiting collectors, to clarify intent and suppress linter warnings. [1] [2] [3] [4]
  • Added a nolint directive to the import of a deprecated Twitter package, documenting the reason for continued use and future replacement.

1batu added 2 commits November 9, 2025 20:17
Added error handling for database queries in metrics and universe handlers to prevent panics and ensure zero values on failure. Improved transaction rollback safety in trading engine. Suppressed unused error warnings in websocket and scraper code. Added a nolint comment for deprecated Twitter package usage.
Add error handling for DB queries and minor code cleanup
@1batu 1batu merged commit a865c32 into DigitalCoreHub:main Nov 9, 2025
1 of 2 checks passed
1batu added a commit that referenced this pull request Nov 9, 2025
Handle error explicitly in service test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant