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

Add cause error information on alternate display#1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
stevenroose wants to merge1 commit intorust-postgres:master
base:master
Choose a base branch
Loading
fromstevenroose:err-alternate
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletionstokio-postgres/src/error/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -379,27 +379,33 @@ impl fmt::Debug for Error {
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0.kind {
Kind::Io => fmt.write_str("error communicating with the server"),
Kind::UnexpectedMessage => fmt.write_str("unexpected message from server"),
Kind::Tls => fmt.write_str("error performing TLS handshake"),
Kind::ToSql(idx) => write!(fmt, "error serializing parameter {idx}"),
Kind::FromSql(idx) => write!(fmt, "error deserializing column {idx}"),
Kind::Column(column) => write!(fmt, "invalid column `{column}`"),
Kind::Io => fmt.write_str("error communicating with the server")?,
Kind::UnexpectedMessage => fmt.write_str("unexpected message from server")?,
Kind::Tls => fmt.write_str("error performing TLS handshake")?,
Kind::ToSql(idx) => write!(fmt, "error serializing parameter {idx}")?,
Kind::FromSql(idx) => write!(fmt, "error deserializing column {idx}")?,
Kind::Column(column) => write!(fmt, "invalid column `{column}`")?,
Kind::Parameters(real, expected) => {
write!(fmt, "expected {expected} parameters but got {real}")
write!(fmt, "expected {expected} parameters but got {real}")?;
}
Kind::Closed => fmt.write_str("connection closed"),
Kind::Db => fmt.write_str("db error"),
Kind::Parse => fmt.write_str("error parsing response from server"),
Kind::Encode => fmt.write_str("error encoding message to server"),
Kind::Authentication => fmt.write_str("authentication error"),
Kind::ConfigParse => fmt.write_str("invalid connection string"),
Kind::Config => fmt.write_str("invalid configuration"),
Kind::RowCount => fmt.write_str("query returned an unexpected number of rows"),
Kind::Closed => fmt.write_str("connection closed")?,
Kind::Db => fmt.write_str("db error")?,
Kind::Parse => fmt.write_str("error parsing response from server")?,
Kind::Encode => fmt.write_str("error encoding message to server")?,
Kind::Authentication => fmt.write_str("authentication error")?,
Kind::ConfigParse => fmt.write_str("invalid connection string")?,
Kind::Config => fmt.write_str("invalid configuration")?,
Kind::RowCount => fmt.write_str("query returned an unexpected number of rows")?,
#[cfg(feature = "runtime")]
Kind::Connect => fmt.write_str("error connecting to server"),
Kind::Timeout => fmt.write_str("timeout waiting for server"),
Kind::Connect => fmt.write_str("error connecting to server")?,
Kind::Timeout => fmt.write_str("timeout waiting for server")?,
}
if fmt.alternate() {
if let Some(ref cause) = self.0.cause {
write!(fmt, ": {cause}")?;
}
}
Ok(())
}
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp