Conversation
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 53 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughImplementations for the Changes
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Reviewer's GuideThis PR adds human‐friendly Display and Error implementations for PushError and WireframeError, along with unit tests to validate their formatted messages and error sources. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/response.rs:103` </location>
<code_context>
+}
+
+impl<E: std::fmt::Debug> std::error::Error for WireframeError<E> {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ match self {
+ WireframeError::Io(e) => Some(e),
</code_context>
<issue_to_address>
Error::source returns None for Protocol even if E might implement Error.
Consider returning Some(e) for the Protocol variant if E implements Error. If returning None is intentional, please document the reasoning.
</issue_to_address>
### Comment 2
<location> `tests/error_display.rs:21` </location>
<code_context>
+impl std::error::Error for ProtoErr {}
+
+#[test]
+fn wireframe_error_messages() {
+ let io_error = std::io::Error::other("socket closed");
+ let io = WireframeError::<ProtoErr>::Io(io_error);
+ assert_eq!(io.to_string(), "transport error: socket closed");
+
+ let proto = WireframeError::Protocol(ProtoErr);
+ assert_eq!(proto.to_string(), "protocol error: ProtoErr");
+}
</code_context>
<issue_to_address>
Add tests for WireframeError::source method.
Please add assertions to test that source() returns the correct value for both Io and Protocol variants of WireframeError.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
#[test]
fn wireframe_error_messages() {
let io_error = std::io::Error::other("socket closed");
let io = WireframeError::<ProtoErr>::Io(io_error);
assert_eq!(io.to_string(), "transport error: socket closed");
let proto = WireframeError::Protocol(ProtoErr);
assert_eq!(proto.to_string(), "protocol error: ProtoErr");
}
=======
#[test]
fn wireframe_error_messages() {
let io_error = std::io::Error::other("socket closed");
let io = WireframeError::<ProtoErr>::Io(io_error);
assert_eq!(io.to_string(), "transport error: socket closed");
let proto = WireframeError::Protocol(ProtoErr);
assert_eq!(proto.to_string(), "protocol error: ProtoErr");
// Test source() for Io variant
let io_error = std::io::Error::other("socket closed");
let io = WireframeError::<ProtoErr>::Io(io_error);
let source = io.source();
assert!(source.is_some());
assert_eq!(source.unwrap().to_string(), "socket closed");
// Test source() for Protocol variant
let proto = WireframeError::Protocol(ProtoErr);
let source = proto.source();
assert!(source.is_some());
assert_eq!(source.unwrap().to_string(), "boom");
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
|
|
||
| impl<E: std::fmt::Debug> std::error::Error for WireframeError<E> { | ||
| fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
There was a problem hiding this comment.
suggestion: Error::source returns None for Protocol even if E might implement Error.
Consider returning Some(e) for the Protocol variant if E implements Error. If returning None is intentional, please document the reasoning.
| #[test] | ||
| fn wireframe_error_messages() { | ||
| let io_error = std::io::Error::other("socket closed"); | ||
| let io = WireframeError::<ProtoErr>::Io(io_error); | ||
| assert_eq!(io.to_string(), "transport error: socket closed"); | ||
|
|
||
| let proto = WireframeError::Protocol(ProtoErr); | ||
| assert_eq!(proto.to_string(), "protocol error: ProtoErr"); | ||
| } |
There was a problem hiding this comment.
suggestion (testing): Add tests for WireframeError::source method.
Please add assertions to test that source() returns the correct value for both Io and Protocol variants of WireframeError.
| #[test] | |
| fn wireframe_error_messages() { | |
| let io_error = std::io::Error::other("socket closed"); | |
| let io = WireframeError::<ProtoErr>::Io(io_error); | |
| assert_eq!(io.to_string(), "transport error: socket closed"); | |
| let proto = WireframeError::Protocol(ProtoErr); | |
| assert_eq!(proto.to_string(), "protocol error: ProtoErr"); | |
| } | |
| #[test] | |
| fn wireframe_error_messages() { | |
| let io_error = std::io::Error::other("socket closed"); | |
| let io = WireframeError::<ProtoErr>::Io(io_error); | |
| assert_eq!(io.to_string(), "transport error: socket closed"); | |
| let proto = WireframeError::Protocol(ProtoErr); | |
| assert_eq!(proto.to_string(), "protocol error: ProtoErr"); | |
| // Test source() for Io variant | |
| let io_error = std::io::Error::other("socket closed"); | |
| let io = WireframeError::<ProtoErr>::Io(io_error); | |
| let source = io.source(); | |
| assert!(source.is_some()); | |
| assert_eq!(source.unwrap().to_string(), "socket closed"); | |
| // Test source() for Protocol variant | |
| let proto = WireframeError::Protocol(ProtoErr); | |
| let source = proto.source(); | |
| assert!(source.is_some()); | |
| assert_eq!(source.unwrap().to_string(), "boom"); | |
| } |
|
@coderabbitai resume |
✅ Actions performedReviews resumed. |
|
@sourcery-ai review |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (2)
src/response.rs (1)
106-110: Error source implementation correctly addresses previous concerns.The implementation properly returns
Some(e)for bothIoandProtocolvariants, which correctly exposes the underlying error source. This addresses the previous review comment about potentially returningNonefor Protocol variants.tests/error_display.rs (1)
7-36: Comprehensive test coverage for error trait implementations.The tests thoroughly cover both
DisplayandError::sourceimplementations for both error types. The use of a helperProtoErrstruct to test protocol errors is well-designed, and the test assertions properly verify the expected behaviour.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/response.rs(1 hunks)tests/error_display.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/error_display.rssrc/response.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/error_display.rssrc/response.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/error_display.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/error_display.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/error_display.rs
🧬 Code Graph Analysis (1)
tests/error_display.rs (2)
src/response.rs (3)
fmt(56-63)fmt(94-99)source(106-111)src/push.rs (1)
fmt(49-54)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (actions)
- GitHub Check: build-test
🔇 Additional comments (1)
tests/error_display.rs (1)
25-39: Minor: keep MSRV flexibility by avoidingstd::io::Error::other
std::io::Error::otheris unavailable on toolchains <1.71. If this crate advertises a wider MSRV, prefer the long-standing constructor:let io_error = std::io::Error::new(std::io::ErrorKind::Other, "socket closed");Not critical if MSRV ≥ 1.71, but worth double-checking.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
DisplayandErrorforPushErrorandWireframeErrorTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_68672877bd40832288a1ab59f7fe1cc6
Summary by Sourcery
Implement user-friendly display messages and error trait support for PushError and WireframeError, and add unit tests to verify their formatting and error sources.
Enhancements:
Tests: