Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7db5bc6

Browse files
committed
fix an Error/Display impl
Types implementing the Error trait should print some inner Error **xor**return that inner Error from its Error::source impl. Otherwise, the sameerror will be printed multiple times when printing an Error's entiresource chain, which is unhelpful.
1 parentbbd1301 commit7db5bc6

File tree

1 file changed

+17
-21
lines changed
  • tokio-postgres/src/error

1 file changed

+17
-21
lines changed

‎tokio-postgres/src/error/mod.rs‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,31 +379,27 @@ impl fmt::Debug for Error {
379379
impl fmt::DisplayforError{
380380
fnfmt(&self,fmt:&mut fmt::Formatter<'_>) -> fmt::Result{
381381
match&self.0.kind{
382-
Kind::Io => fmt.write_str("error communicating with the server")?,
383-
Kind::UnexpectedMessage => fmt.write_str("unexpected message from server")?,
384-
Kind::Tls => fmt.write_str("error performing TLS handshake")?,
385-
Kind::ToSql(idx) =>write!(fmt,"error serializing parameter {idx}")?,
386-
Kind::FromSql(idx) =>write!(fmt,"error deserializing column {idx}")?,
387-
Kind::Column(column) =>write!(fmt,"invalid column `{column}`")?,
382+
Kind::Io => fmt.write_str("error communicating with the server"),
383+
Kind::UnexpectedMessage => fmt.write_str("unexpected message from server"),
384+
Kind::Tls => fmt.write_str("error performing TLS handshake"),
385+
Kind::ToSql(idx) =>write!(fmt,"error serializing parameter {idx}"),
386+
Kind::FromSql(idx) =>write!(fmt,"error deserializing column {idx}"),
387+
Kind::Column(column) =>write!(fmt,"invalid column `{column}`"),
388388
Kind::Parameters(real, expected) =>{
389-
write!(fmt,"expected {expected} parameters but got {real}")?
389+
write!(fmt,"expected {expected} parameters but got {real}")
390390
}
391-
Kind::Closed => fmt.write_str("connection closed")?,
392-
Kind::Db => fmt.write_str("db error")?,
393-
Kind::Parse => fmt.write_str("error parsing response from server")?,
394-
Kind::Encode => fmt.write_str("error encoding message to server")?,
395-
Kind::Authentication => fmt.write_str("authentication error")?,
396-
Kind::ConfigParse => fmt.write_str("invalid connection string")?,
397-
Kind::Config => fmt.write_str("invalid configuration")?,
398-
Kind::RowCount => fmt.write_str("query returned an unexpected number of rows")?,
391+
Kind::Closed => fmt.write_str("connection closed"),
392+
Kind::Db => fmt.write_str("db error"),
393+
Kind::Parse => fmt.write_str("error parsing response from server"),
394+
Kind::Encode => fmt.write_str("error encoding message to server"),
395+
Kind::Authentication => fmt.write_str("authentication error"),
396+
Kind::ConfigParse => fmt.write_str("invalid connection string"),
397+
Kind::Config => fmt.write_str("invalid configuration"),
398+
Kind::RowCount => fmt.write_str("query returned an unexpected number of rows"),
399399
#[cfg(feature ="runtime")]
400-
Kind::Connect => fmt.write_str("error connecting to server")?,
401-
Kind::Timeout => fmt.write_str("timeout waiting for server")?,
402-
};
403-
ifletSome(ref cause) =self.0.cause{
404-
write!(fmt,": {cause}")?;
400+
Kind::Connect => fmt.write_str("error connecting to server"),
401+
Kind::Timeout => fmt.write_str("timeout waiting for server"),
405402
}
406-
Ok(())
407403
}
408404
}
409405

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp