Skip to content

Commit b0e780f

Browse files
committed
Fix typos
1 parent 9624789 commit b0e780f

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

ch_09/handle-errors/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ impl std::fmt::Display for Error {
5555
}
5656
}
5757

58+
const DUPLICATE_KEY: u32 = 23505;
59+
5860
impl Reject for Error {}
5961
impl Reject for APILayerError {}
6062

@@ -65,7 +67,7 @@ pub async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> {
6567

6668
match e {
6769
sqlx::Error::Database(err) => {
68-
if err.code().unwrap().parse::<i32>().unwrap() == 23505 {
70+
if err.code().unwrap().parse::<u32>().unwrap() == DUPLICATE_KEY {
6971
Ok(warp::reply::with_status(
7072
"Account already exsists".to_string(),
7173
StatusCode::UNPROCESSABLE_ENTITY,

ch_10/handle-errors/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ impl std::fmt::Display for Error {
6060
impl Reject for Error {}
6161
impl Reject for APILayerError {}
6262

63+
const DUPLICATE_KEY: u32 = 23505;
64+
6365
#[instrument]
6466
pub async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> {
6567
if let Some(crate::Error::DatabaseQueryError(e)) = r.find() {
6668
event!(Level::ERROR, "Database query error");
6769

6870
match e {
6971
sqlx::Error::Database(err) => {
70-
if err.code().unwrap().parse::<i32>().unwrap() == 23505 {
72+
if err.code().unwrap().parse::<u32>().unwrap() == DUPLICATE_KEY {
7173
Ok(warp::reply::with_status(
7274
"Account already exsists".to_string(),
7375
StatusCode::UNPROCESSABLE_ENTITY,

ch_11/handle-errors/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ impl std::fmt::Display for Error {
6060
impl Reject for Error {}
6161
impl Reject for APILayerError {}
6262

63+
const DUPLICATE_KEY: u32 = 23505;
64+
6365
#[instrument]
6466
pub async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> {
6567
if let Some(crate::Error::DatabaseQueryError(e)) = r.find() {
6668
event!(Level::ERROR, "Database query error");
6769

6870
match e {
6971
sqlx::Error::Database(err) => {
70-
if err.code().unwrap().parse::<i32>().unwrap() == 23505 {
72+
if err.code().unwrap().parse::<u32>().unwrap() == DUPLICATE_KEY {
7173
Ok(warp::reply::with_status(
7274
"Account already exsists".to_string(),
7375
StatusCode::UNPROCESSABLE_ENTITY,

ch_11/src/types/pagination.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod pagination_tests {
7272
}
7373

7474
#[test]
75-
fn missing_offset_paramater() {
75+
fn missing_offset_parameter() {
7676
let mut params = HashMap::new();
7777
params.insert(String::from("limit"), String::from("1"));
7878

0 commit comments

Comments
 (0)