[codex] Split preferred editor precondition errors - #3324
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
ApprovabilityVerdict: Approved This PR refactors error handling by splitting one error class into two more specific ones with structured properties. The runtime behavior remains the same - errors are thrown in identical conditions, just with better typing and messages. Low-risk code quality improvement. You can customize Macroscope's approvability policy. Learn more. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 9f64e27
Summary
No behavior test was added for this pure error-model refactor.
Validation
Note
Split
useOpenInPreferredEditorprecondition errors into distinct typed errorsPreferredEditorEnvironmentRequiredErrorfor the case where no environment is selected, carryingtargetPathand a specific message.PreferredEditorUnavailableErrorinto aSchema.TaggedErrorClasswith structured fields:environmentId,targetPath, andavailableEditorIds.useOpenInPreferredEditorhook now returns distinct error types for these two failure cases instead of reusing a single error class.Macroscope summarized 9f64e27.
Note
Low Risk
Localized change to editor open preconditions in
editorPreferences.ts; callers must handle an additional error tag if they pattern-match failures.Overview
useOpenInPreferredEditornow returns two discriminable precondition failures instead of one genericPreferredEditorUnavailableErrorwith a free-form message.When
environmentIdis null, callers getPreferredEditorEnvironmentRequiredErrorwithtargetPath. When no editor can be resolved, they getPreferredEditorUnavailableErrorcarryingenvironmentId,targetPath, andavailableEditorIds. Both types move fromData.TaggedErrortoSchema.TaggedErrorClass, with user-facing text from amessagegetter rather than caller-supplied strings.The hook’s result error union is updated accordingly. Any code that only handled
PreferredEditorUnavailableErrorfor the “no environment” case must handlePreferredEditorEnvironmentRequiredErrorseparately.Reviewed by Cursor Bugbot for commit 9f64e27. Bugbot is set up for automated code reviews on this repo. Configure here.