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