Merge pull request #90 from jgallagher/fix-str-error-messages

Fix error messages when failing to convert paths and strings to C-compatible versions
This commit is contained in:
John Gallagher 2015-12-01 11:49:37 -05:00
commit 9a4503ad5f

View File

@ -128,14 +128,14 @@ impl SqliteError {
fn str_to_cstring(s: &str) -> SqliteResult<CString> { fn str_to_cstring(s: &str) -> SqliteResult<CString> {
CString::new(s).map_err(|_| SqliteError{ CString::new(s).map_err(|_| SqliteError{
code: ffi::SQLITE_MISUSE, code: ffi::SQLITE_MISUSE,
message: "Could not convert path to C-combatible string".to_string() message: format!("Could not convert string {} to C-combatible string", s),
}) })
} }
fn path_to_cstring(p: &Path) -> SqliteResult<CString> { fn path_to_cstring(p: &Path) -> SqliteResult<CString> {
let s = try!(p.to_str().ok_or(SqliteError{ let s = try!(p.to_str().ok_or(SqliteError{
code: ffi::SQLITE_MISUSE, code: ffi::SQLITE_MISUSE,
message: "Could not convert path to UTF-8 string".to_string() message: format!("Could not convert path {} to UTF-8 string", p.to_string_lossy()),
})); }));
str_to_cstring(s) str_to_cstring(s)
} }