Add comprehensive error handling to Player API creation endpoints#65
Draft
sei-awelle wants to merge 3 commits intomainfrom
Draft
Add comprehensive error handling to Player API creation endpoints#65sei-awelle wants to merge 3 commits intomainfrom
sei-awelle wants to merge 3 commits intomainfrom
Conversation
Simplified approach that focuses on what matters: - Parse PostgreSQL error codes (23505, 23503, 23514) into actionable messages - Keep input validation for early failure detection - Let ExceptionMiddleware handle all logging automatically Changes: - **Views/Create.cs**: PostgreSQL error handling, name validation - **Teams/Create.cs**: PostgreSQL error handling, ViewId/RoleId validation - **Users/Create.cs**: PostgreSQL error handling, name validation - **Applications/Create.cs**: PostgreSQL error handling, ViewId validation - **ApplicationInstance/Create.cs**: PostgreSQL error handling, FK validation Benefits: - Clear error messages like 'Invalid ViewId X. The View does not exist.' - ExceptionMiddleware logs all exceptions with full context - Less code, same debugging capability
372949b to
05e7f1b
Compare
Centralized database error handling in middleware: - Added TransformPostgresException method to ExceptionMiddleware - Removed all try/catch blocks from Create handlers - Removed unused logger parameters from handler constructors - Removed unused using statements (Microsoft.Extensions.Logging, Npgsql) Simplified handlers for: - Applications/Create.cs: Removed 32 lines of error handling - Teams/Create.cs: Removed 33 lines of error handling - Users/Create.cs: Removed 32 lines of error handling - Views/Create.cs: Removed 35 lines of error handling This matches the pattern established in Caster API PR #77. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sanitize database error messages for security: - Log detailed PostgreSQL info (table, constraint, message) for debugging - Always return generic user-friendly messages to users - Never expose database internals to prevent information leakage - Matches security improvements in Caster API PR #77
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
Changes
Benefits
Testing