Merged
Conversation
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
added a commit
that referenced
this pull request
Nov 9, 2025
Handle error explicitly in service test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
metrics_handler.goand set default values if queries fail, preventing potential panics and ensuring Prometheus metrics are always returned with valid values. [1] [2]GetActiveStocksinuniverse_handler.go, setting zero values on failure to avoid returning incomplete or nil data.trading_engine.goto safely ignore rollback errors if the transaction was already committed, preventing misleading error logs.Resource and API usage improvements:
_ = ...) 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]nolintdirective to the import of a deprecated Twitter package, documenting the reason for continued use and future replacement.