Skip to content

Commit

Permalink
Improves error
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Jan 15, 2025
1 parent f35fe2b commit 4b1ad12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/connection/_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl Connection {
let status = unsafe { pq_sys::PQsetnonblocking(self.into(), non_blocking as i32) };

if status < 0 {
Err(crate::errors::Error::Unknow)
self.error()
} else {
Ok(())
}
Expand Down Expand Up @@ -285,7 +285,7 @@ impl Connection {
if status == 0 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
self.error()
}
}

Expand All @@ -305,7 +305,7 @@ impl Connection {
if status == 0 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
self.error()
}
}

Expand All @@ -326,7 +326,7 @@ impl Connection {
if status == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
self.error()
}
}
}
4 changes: 2 additions & 2 deletions src/connection/_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Connection {
-1 => self.error(),
0 => Err(crate::errors::Error::Backend("Full buffers".to_string())),
1 => Ok(()),
_ => Err(crate::errors::Error::Unknow),
_ => self.error(),
}
}

Expand All @@ -50,7 +50,7 @@ impl Connection {
-1 => self.error(),
0 => Err(crate::errors::Error::Backend("Full buffers".to_string())),
1 => Ok(()),
_ => Err(crate::errors::Error::Unknow),
_ => self.error(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/connection/_single_row_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Connection {
if success == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
self.error()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/connection/_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Connection {
let socket = unsafe { pq_sys::PQsocket(self.into()) };

if socket < 0 {
Err(crate::errors::Error::Unknow)
self.error()
} else {
Ok(socket)
}
Expand Down
8 changes: 4 additions & 4 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn enter(conn: &crate::Connection) -> crate::errors::Result {
if success == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
conn.error()
}
}

Expand All @@ -56,7 +56,7 @@ pub fn exit(conn: &crate::Connection) -> crate::errors::Result {
if success == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
conn.error()
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ pub fn sync(conn: &crate::Connection) -> crate::errors::Result {
if success == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
conn.error()
}
}

Expand All @@ -101,7 +101,7 @@ pub fn flush_request(conn: &crate::Connection) -> crate::errors::Result {
if success == 1 {
Ok(())
} else {
Err(crate::errors::Error::Unknow)
conn.error()
}
}

Expand Down

0 comments on commit 4b1ad12

Please sign in to comment.