Skip to content

refactor(core): introduce unified QueryaDatabaseException hierarchy - #1085

Merged
ZhuchkaTriplesix merged 1 commit into
mainfrom
issue/1037-database-exception-hierarchy
Oct 7, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
mainfrom
issue/1037-database-exception-hierarchy

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

  • New sealed QueryaDatabaseException family in lib/core/database/querya_database_exception.dart: AuthFailedException, HostUnreachableException, ConnectionTimeoutException, DatabaseNotFoundException, TableNotFoundException, QuerySyntaxException, LockTimeoutException and an UnknownDatabaseException fallback. Each carries a message, optional explanation, remediation hint, original error and stack trace.
  • mapDatabaseError / describeDatabaseError in database_error_mapper.dart map PostgreSQL, MySQL, SQLite, MongoDB and Redis errors (including wrapped *ConnectionException.cause, SocketException, TimeoutException).
  • Connect failures now use it: PostgreSQL/MySQL/SQLite pool and connect messages embed the friendly text with the hint; MySQL, MongoDB and Redis connect() rethrow a recognized QueryaDatabaseException. Unrecognized errors keep their original type and text, so existing typed errors (*ConnectionException) are unchanged.
  • Unit tests for the mapping across all drivers in test/core/database/database_error_mapper_test.dart.

The existing *ConnectionException classes stay as they are; a sealed class cannot be extended outside its library, so they are mapped rather than subclassed.

Closes #1037

… mapper (#1037)

Add a sealed QueryaDatabaseException family (auth, host unreachable,
timeout, database/table not found, syntax, lock timeout) with remediation
hints, a mapper for PostgreSQL, MySQL, SQLite, MongoDB and Redis errors,
and use it for connect failures so users see plain messages with hints.
@github-actions github-actions Bot added enhancement New feature or request error-handling Theme parser epic label: error-handling core Core library logic and services connections Database connections, URI parsing, pools P2 Medium priority / Parity & Refactoring labels Oct 7, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 0bea03b into main Oct 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connections Database connections, URI parsing, pools core Core library logic and services enhancement New feature or request error-handling Theme parser epic label: error-handling P2 Medium priority / Parity & Refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(core): introduce unified QueryaDatabaseException hierarchy

1 participant