Skip to content

Swap additional context and label in I/O errors - #14954

Merged
fdncred merged 4 commits into
nushell:mainfrom
132ikl:io-error-tweak
Feb 3, 2025
Merged

fdncred merged 4 commits into
nushell:mainfrom
132ikl:io-error-tweak

Conversation

@132ikl

@132ikl 132ikl commented Jan 29, 2025

Copy link
Copy Markdown
Member

Description

Tweaks the error style for I/O errors introduced #14927. Moves the additional context to below the text that says "I/O error", and always shows the error kind in the label.

Additional context Before PR After PR
yes image image
no image image

User-Facing Changes

N/A, as this is a follow-up to #14927 which has not been included in a release

Tests + Formatting

N/A

After Submitting

N/A

@132ikl
132ikl marked this pull request as ready for review January 29, 2025 01:46
@132ikl 132ikl added notes:mention Noted in "Hall of Fame" section deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead pr:screenshot and removed notes:mention Noted in "Hall of Fame" section labels Jan 29, 2025
Comment on lines +330 to +336
impl std::error::Error for AdditionalContext {}

impl From<String> for AdditionalContext {
fn from(value: String) -> Self {
AdditionalContext(value)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you derive the struct with thiserror::Error as I stated, you can remove this entirely.

Suggested change
impl std::error::Error for AdditionalContext {}
impl From<String> for AdditionalContext {
fn from(value: String) -> Self {
AdditionalContext(value)
}
}

Comment on lines +393 to +396
match &self.additional_context {
Some(ctx) => Some(ctx as &dyn Diagnostic),
None => None,
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At this point, you don't need to match anymore

Suggested change
match &self.additional_context {
Some(ctx) => Some(ctx as &dyn Diagnostic),
None => None,
}
self.additional_context.as_ref().map(|ctx| ctx as &dyn Diagnostic)

@132ikl 132ikl Feb 3, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I knew there was a way to do this with map, I must've missed as_ref. Thanks! Resolved by 1954a29

@132ikl

132ikl commented Feb 3, 2025

Copy link
Copy Markdown
Member Author

@cptpiepmatz should be good now, let me know what you think. you seemed on the fence about this, so if you're not sure I can hold off and get some extra opinions from core team, otherwise I can merge before the release

@cptpiepmatz

Copy link
Copy Markdown
Member

I know again why I initially disliked this. I had it set up similar to this before I had the Location up, so you lost some information. I like how this one looks now.

@fdncred
fdncred merged commit f04db2a into nushell:main Feb 3, 2025
@fdncred

fdncred commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.102.0 milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants