mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-24 04:00:40 +00:00
error message suggests possible causes Addressed code review 1 thread + smaller heap size
This commit is contained in:
11
src/error.rs
11
src/error.rs
@@ -9,6 +9,7 @@ use schema;
|
||||
use serde_json;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::PoisonError;
|
||||
use core::LOCKFILE_FILEPATH;
|
||||
|
||||
/// The library's failure based error enum
|
||||
#[derive(Debug, Fail)]
|
||||
@@ -19,6 +20,9 @@ pub enum TantivyError {
|
||||
/// File already exists, this is a problem when we try to write into a new file.
|
||||
#[fail(display = "file already exists: '{:?}'", _0)]
|
||||
FileAlreadyExists(PathBuf),
|
||||
/// Lockfile already exists
|
||||
#[fail(display = "Lockfile '{:?}' already exists. Possible causes: another IndexWriter instance or panic during previous lock drop.", _0)]
|
||||
LockFileAlreadyExists(PathBuf),
|
||||
/// IO Error.
|
||||
#[fail(display = "an IO error occurred: '{}'", _0)]
|
||||
IOError(#[cause] IOError),
|
||||
@@ -95,7 +99,12 @@ impl From<OpenWriteError> for TantivyError {
|
||||
fn from(error: OpenWriteError) -> TantivyError {
|
||||
match error {
|
||||
OpenWriteError::FileAlreadyExists(filepath) => {
|
||||
TantivyError::FileAlreadyExists(filepath)
|
||||
let lockfile_fname = LOCKFILE_FILEPATH.to_str().unwrap();
|
||||
if filepath.ends_with(lockfile_fname) {
|
||||
TantivyError::LockFileAlreadyExists(filepath)
|
||||
} else {
|
||||
TantivyError::FileAlreadyExists(filepath)
|
||||
}
|
||||
}
|
||||
OpenWriteError::IOError(io_error) => TantivyError::IOError(io_error),
|
||||
}.into()
|
||||
|
||||
Reference in New Issue
Block a user