Add structured SQL error reporting with rich context#53
Merged
Conversation
…hints Replaces generic string errors with StructuredError type that extracts rich information from PostgreSQL error responses: error category (syntax/semantic/execution/transaction/connection), SQLSTATE code, line and column numbers from byte position, detail, hint, schema/table/ column/constraint context, and PL/pgSQL call stack. The results panel now renders errors with color-coded categories, position info, and contextual hints instead of plain text. Closes #44 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Run cargo fmt for consistent code formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Option<String>error field withStructuredErrortype that extracts rich information from PostgreSQLDbErrorresponsesImplementation Details
src/db/query.rsErrorCategoryenum withSyntax,Semantic,Execution,Transaction,Connection,UnknownvariantsStructuredErrorstruct with fields: category, severity, code, message, detail, hint, position, line, col, schema, table, column, constraint, where_from_pg_error()to extract rich info fromtokio_postgres::Errorviaas_db_error()APIbyte_offset_to_line_col()to convert PostgreSQL's 1-based byte position to (line, column)categorize_sqlstate()mapping SQLSTATE class codes to error categoriesQueryResult.errorfromOption<String>toOption<StructuredError>src/ui/components.rsdraw_structured_error()function rendering rich error display with:src/ui/app.rsError Category Mapping
Test plan
cargo buildcompiles without warningscargo test- all 230 tests passCloses #44
🤖 Generated with Claude Code