Skip to content

Conversation

@alienx5499
Copy link
Contributor

Summary

This PR improves code quality by adding const correctness, better error handling, and additional utility methods to the SQLite wrapper class.

Changes

  • include/libp2p/storage/sqlite.hpp: Enhanced method declarations with const correctness and better documentation
  • src/storage/sqlite.cpp: Improved implementations with better error handling and new utility methods

Methods Updated

  • getErrorCode() - Returns SQLite extended error code (const)
  • getErrorMessage() - Returns human-readable error message (const)
  • countChanges() - Returns number of rows modified (const)
  • getDatabaseFile() - Returns database file path (const, new)
  • getStatementCount() - Returns number of prepared statements (const, new)
  • getStatement() - Improved error messages with detailed handle information
  • execCommand() - Better error handling and documentation
  • execQuery() - Better error handling and documentation

Benefits

  • Better API Design: Methods that don't modify state are properly marked as const
  • Improved Error Handling: More descriptive error messages and proper exception handling
  • Enhanced Debugging: New utility methods for database file path and statement count
  • Code Clarity: Better documentation and more informative error messages
  • C++ Best Practices: Follows modern C++ const correctness and exception safety guidelines
  • Better Exception Safety: Proper re-throwing of programming errors vs runtime errors

Testing

  • No breaking changes - all improvements are additive
  • Existing functionality remains unchanged
  • New utility methods provide additional debugging capabilities
  • Improved error messages help with troubleshooting

@alienx5499
Copy link
Contributor Author

@turuslan Could you please review this PR when you get a chance?

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