I use diesel and postgres for my rust project.
The problem i am struggling with right now is when i insert_into the table there are different errors that can occur and i want to take different actions for the different error types.
Those are the Errors: Diesel DatabaseErrorKind
And i want to do something like this (source):
use std::fs::File;
use std::io::ErrorKind;
fn main() {
let f = File::open("hello.txt");
let f = match f {
Ok(file) => file,
Err(error) => match error.kind() {
ErrorKind::NotFound => match File::create("hello.txt") {
Ok(fc) => fc,
Err(e) => panic!("Problem creating the file: {:?}", e),
},
other_error => {
panic!("Problem opening the file: {:?}", other_error)
}
},
};
}
The problem is that there is no error.kind() for the diesel error.