Skip to content

refactor: replace unsafe unwrap() calls with expect() containing context - #93

Merged
echobt merged 1 commit into
mainfrom
fix/pr26-unwrap-to-expect
Feb 4, 2026
Merged

refactor: replace unsafe unwrap() calls with expect() containing context#93
echobt merged 1 commit into
mainfrom
fix/pr26-unwrap-to-expect

Conversation

@echobt

Copy link
Copy Markdown
Contributor

Replaces PR #26 which had merge conflicts.

This PR replaces the unsafe .unwrap() call in runner.rs with .expect() containing context message for better debugging when the assertion fails.

Closes#26

@greptile-apps

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

replaced unsafe .unwrap() with .expect() containing descriptive context message in the init_client method at src/cortex-exec/src/runner.rs:190-194

  • improved error messages for debugging when ModelClient initialization assertion fails
  • maintains the same runtime behavior while providing better panic messages
  • the change is safe because the client is guaranteed to be initialized in the preceding if block (lines 171-187)

Confidence Score: 5/5

  • This PR is completely safe to merge with no risk
  • The change is a simple refactoring that replaces .unwrap() with .expect() containing a descriptive error message. This improves error handling without changing runtime behavior or logic. The code is guaranteed to be safe due to the initialization check in the preceding block.
  • No files require special attention

Important Files Changed

FilenameOverview
src/cortex-exec/src/runner.rsreplaced .unwrap() with .expect() containing context message in init_client method for better error debugging

Sequence Diagram

sequenceDiagram
participant Caller
participant ExecRunner
participant ModelClient
Caller->>ExecRunner: init_client()
ExecRunner->>ExecRunner: Check if client is None
alt client is None
ExecRunner->>ModelClient: create_client()
ModelClient-->>ExecRunner: Return new client
ExecRunner->>ExecRunner: Set self.client = Some(client)
end
ExecRunner->>ExecRunner: expect("ModelClient should be initialized")
ExecRunner-->>Caller: Return &dyn ModelClient
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@echobt
echobt merged commit f8c6f03 into mainFeb 4, 2026
15 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@echobt