Skip to content

Rewrite send::error::ResponseError docs - #307

Merged
DanGould merged 2 commits into
payjoin:masterfrom
jbesraa:2024-06-26-response-error-docs
Jul 1, 2024
Merged

Rewrite send::error::ResponseError docs#307
DanGould merged 2 commits into
payjoin:masterfrom
jbesraa:2024-06-26-response-error-docs

Conversation

@jbesraa

@jbesraa jbesraa commented Jun 27, 2024

Copy link
Copy Markdown
Contributor

noticed the docs are kind of bad while reviewing #304

resolves #306

@DanGould DanGould left a comment

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.

Helpful changes. Thanks!

Can you be more specific with your issue however? What do you mean when you say documentation is "kind of bad"

Comment thread payjoin/src/send/error.rs Outdated
Comment on lines +274 to +278
/// `WellKnown` errors following the BIP78 spec
/// https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki#user-content-Receivers_well_known_errors
/// These errors are displayed to end users.
/// Errors that are defined in the [`BIP78`] spec.
///
/// The `WellKnownError` represents `errorCode` and `message`.
/// It is safe to display these errors to end users.
///
/// [`BIP78`]: https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki#user-content-Receivers_well_known_errors

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.

I prefer that the original explicitly said "WellKnown errors". There are lots of errors defined in the bip78 spec, these are explicitly called "Well-known" errors

I do also prefer your wording "It is safe to display these errors to end users."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.
I was looking into the spec and could not find another errors, could you be please share a link to errors beside the ReceiverWellKnown ?

Comment thread payjoin/src/send/error.rs Outdated
Comment on lines +280 to +284
/// `Unrecognized` errors are errors that are not well known and are only displayed in debug logs.
/// They are not displayed to end users.
/// Errors out of the scope of the [`BIP78`] spec.
///
/// These errors are only displayed in debug logs.
///
/// [`BIP78`]: https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki#user-content-Receivers_well_known_errors

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.

I prefer the original first sentence. It would be good for this to mirror the first change you made

"They are not displayed to end users." -> "Unrecognized errors are not safe to display to end users because they could be used maliciously to phish a non technical user. Only display them in debug logs."

Adding the link is a great idea.

Comment thread payjoin/src/send/error.rs
/// They are only displayed in debug logs.
/// Errors caused by malformed responses.
///
/// These errors are only displayed in debug logs.

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.

The comment change is fine but "These errors are only displayed in debug logs" is false statement impl Display for ResponseError writes the ValidationError in the match arm for ResponseError::Validation

Consider fixing the Display implementation to only write a fixed string.

Self::Validation(e) => write!(f, "The receiver sent an invalid response: {}", e),

@jbesraa
jbesraa force-pushed the 2024-06-26-response-error-docs branch 2 times, most recently from 9bf956c to 4a29240 Compare July 1, 2024 15:02
@jbesraa
jbesraa force-pushed the 2024-06-26-response-error-docs branch from 4a29240 to 68c2e4f Compare July 1, 2024 15:07
@jbesraa

jbesraa commented Jul 1, 2024

Copy link
Copy Markdown
Contributor Author

@DanGould revisited issue body plus addressed your comments and added new commit to resolve the Validation printing in Display

@DanGould DanGould left a comment

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.

Thank you. So much cleaner than before. Excellent.

Comment thread payjoin/src/send/error.rs
/// `WellKnown` errors following the BIP78 spec
/// https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki#user-content-Receivers_well_known_errors
/// These errors are displayed to end users.
/// `WellKnown` Errors are defined in the [`BIP78::ReceiverWellKnownError`] spec.

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.

I find the use of :: to identify the receiver spec a bit odd since it's not referencing a rust module element but it does get the point across

@DanGould
DanGould merged commit 2d45fd4 into payjoin:master Jul 1, 2024
Sign up for free to 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.

rewrite ResponseError docs

2 participants