Update error checking example

This commit is contained in:
Steven Fackler 2014-02-15 18:28:10 -08:00
parent e83e64c09c
commit ea45cef780

View File

@ -160,9 +160,10 @@ methods, there is a second variant prefixed with `try_` which returns a
match conn.try_execute(query, params) {
Ok(updates) => println!("{} rows were updated", updates),
Err(err) => match err.code {
NotNullViolation => println!("Something was NULL that shouldn't be"),
SyntaxError => println!("Invalid query syntax"),
_ => println!("A bad thing happened: {}", err.message),
PgDbError(NotNullViolation) =>
println!("Something was NULL that shouldn't be"),
PgDbError(SyntaxError) => println!("Invalid query syntax"),
_ => println!("A bad thing happened: {}", err),
}
}
```