Repository navigation
Remove try-catch blocks from AdPentest.aspx - #74
Open
netanelcyber wants to merge 1 commit into
Open
netanelcyber wants to merge 1 commit into
netanelcyber wants to merge 1 commit into
Conversation
- bImport_Click: replace try-catch with guard clauses and early returns for validation; extract TryPopulateImport helper for parse errors - SaveAndDisplayAsync: remove outer try-catch, use early returns with ShowMessage + ShowReport for each error path - BindHistoryAsync / LoadReportAsync: remove wrapping try-catch entirely - StopProcessTreeAsync: replace nested try-catch with IsProcessRunning guard and specific Win32Exception catch on Process.Start only - Cancellation registration: remove try-catch, use IsProcessRunning guard - bRun_Click error recovery: extract TryMarkRowErrorAsync helper - DB unique constraint: extract TrySaveUniqueAsync helper, reuse in both RunScanBackgroundAsync and SaveAndDisplayAsync - Extract TryPopulateReport helper for background scan JSON parsing Reduces catch blocks from 14 to 7, with remaining ones isolated in small, focused helper methods or genuinely required (background task error recording, semaphore cleanup). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ni4YjEC33HpqKZxGw6gMu
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Requested by NETANEL · project thread
Before: 14 try-catch blocks scattered through the main code paths —
bImport_Click,SaveAndDisplayAsync,BindHistoryAsync,LoadReportAsync, andStopProcessTreeAsyncall wrapped in broad exception handlers, with emptycatch {}blocks and nested try-catch chains.After: Main code paths use guard clauses and early returns instead of try-catch. Remaining 7 catch blocks are isolated in small, focused helper methods (
TrySaveUniqueAsync,IsProcessRunning,TryPopulateImport,TryPopulateReport,TryMarkRowErrorAsync) or genuinely required (background task error recording, semaphore cleanup).The refactoring replaces exception-based control flow with explicit conditionals: validation in
bImport_Clicknow uses early returns,SaveAndDisplayAsyncusesShowMessage+returnat each error path, andStopProcessTreeAsyncuses anIsProcessRunningguard instead of nested try-catch-catch chains.How: Extracted five helper methods that encapsulate the unavoidable catch blocks (process management, DB constraint races, JSON parsing). Removed the wrapping try-catch from
BindHistoryAsyncandLoadReportAsyncentirely. Replaced the cancellation-token registration's inline try-catch with anIsProcessRunningguard.🤖 Generated with Claude Code
https://claude.ai/code/session_015ni4YjEC33HpqKZxGw6gMu
Generated by Claude Code