Update error checking example
This commit is contained in:
parent
e83e64c09c
commit
ea45cef780
@ -160,9 +160,10 @@ methods, there is a second variant prefixed with `try_` which returns a
|
|||||||
match conn.try_execute(query, params) {
|
match conn.try_execute(query, params) {
|
||||||
Ok(updates) => println!("{} rows were updated", updates),
|
Ok(updates) => println!("{} rows were updated", updates),
|
||||||
Err(err) => match err.code {
|
Err(err) => match err.code {
|
||||||
NotNullViolation => println!("Something was NULL that shouldn't be"),
|
PgDbError(NotNullViolation) =>
|
||||||
SyntaxError => println!("Invalid query syntax"),
|
println!("Something was NULL that shouldn't be"),
|
||||||
_ => println!("A bad thing happened: {}", err.message),
|
PgDbError(SyntaxError) => println!("Invalid query syntax"),
|
||||||
|
_ => println!("A bad thing happened: {}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user