diff --git a/src/error.rs b/src/error.rs index dccb33474..d6ce4a33d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -/// Definition of Tantivy's error and result. +//! Definition of Tantivy's error and result. use std::io; @@ -12,37 +12,48 @@ use serde_json; error_chain!( errors { + /// Path does not exist. PathDoesNotExist(buf: PathBuf) { description("path does not exist") display("path does not exist: '{:?}'", buf) } + /// File already exists, this is a problem when we try to write into a new file. FileAlreadyExists(buf: PathBuf) { description("file already exists") display("file already exists: '{:?}'", buf) } + /// IO Error. IOError(err: IOError) { description("an IO error occurred") display("an IO error occurred: '{}'", err) } + /// The data within is corrupted. + /// + /// For instance, it contains invalid JSON. CorruptedFile(buf: PathBuf) { description("file contains corrupted data") display("file contains corrupted data: '{:?}'", buf) } + /// A thread holding the locked panicked and poisoned the lock. Poisoned { description("a thread holding the locked panicked and poisoned the lock") } + /// Invalid argument was passed by the user. InvalidArgument(arg: String) { description("an invalid argument was passed") display("an invalid argument was passed: '{}'", arg) } + /// An Error happened in one of the thread. ErrorInThread(err: String) { description("an error occurred in a thread") display("an error occurred in a thread: '{}'", err) } + /// An Error appeared related to the lack of a field. SchemaError(field: String) { description("a schema field is missing") display("a schema field is missing: '{}'", field) } + /// Tried to access a fastfield reader for a field not configured accordingly. FastFieldError(err: FastFieldNotAvailableError) { description("fast field not available") display("fast field not available: '{:?}'", err) diff --git a/src/lib.rs b/src/lib.rs index 00f4a7b9f..37881ebe2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,7 +86,7 @@ mod functional_test; #[macro_use] mod macros; -pub use error::Error; +pub use error::{Error, ErrorKind}; /// Tantivy result. pub type Result = std::result::Result;