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

Make error::Kind public#1185

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
levkk wants to merge3 commits intorust-postgres:master
base:master
Choose a base branch
Loading
fromlevkk:levkk-make-error-pub
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

Some comments aren't visible on the classic Files Changed page.

21 changes: 18 additions & 3 deletionstokio-postgres/src/error/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,15 +337,25 @@ pub enum ErrorPosition {
},
}

#[derive(Debug, PartialEq)]
enum Kind {
/// Error kind returned by the database.
#[allow(missing_docs)]
#[derive(Debug, PartialEq, Clone)]
#[non_exhaustive]
pub enum Kind {
Io,
UnexpectedMessage,
Tls,
ToSql(usize),
FromSql(usize),
Comment on lines 347 to 348
Copy link
Member

@paolobarbolinipaolobarboliniSep 20, 2025
edited
Loading

Choose a reason for hiding this comment

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

Theseusizes are very ambiguous. Is this the index of the column? We should document it.

EDIT: or even convert it into something along the lines of:

FromSql{column_index: usize,}

/// A column was fetched from the row which wasn't returned by the database.
/// This usually indicates the column wasn't included in the query.
Column(String),
Parameters(usize, usize),
/// The number of parameters expected by the query doesn't match the number
/// of parameters passed when executing the prepared statement.
Parameters {
expected: usize,
found: usize,
},
Closed,
Db,
Parse,
Expand DownExpand Up@@ -438,6 +448,11 @@ impl Error {
self.as_db_error().map(DbError::code)
}

/// Returns the kind of error.
pub fn kind(&self) -> &Kind {
&self.0.kind
}

fn new(kind: Kind, cause: Option<Box<dyn error::Error + Sync + Send>>) -> Error {
Error(Box::new(ErrorInner { kind, cause }))
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp