pub enum ErrorKind {
Show 13 variants
ContextLock,
ContextInconsistent,
ScopeNotInitialized,
KeyNotInitialized,
ParseEnv,
ParseArg,
EnvType,
UnknownLogLevel,
WriteFailed,
InvalFmtString,
LogCompatInitialized,
TaskLocal(TaskLocalErr),
IoError(ErrorKind),
}
Expand description
A list of possible errors that can occur in this library
This list is intended to be grow over time and is not recommended to be exhaustively matched.
It is used with the Result
type to signal that an error occurred.
The IoError
variant is used to catch any underlying std::io::Errors
without mapping them to internal error(s). This allows a better control over underling
errors instead of “hiding” them.
§Handling errors and matching ErrorKind
In application code match
against the expected ErrorKind
, use _
to match all
other Errors.
use hclog::{ErrorKind};
match hclog::dump(&mut std::io::stdout()) {
Ok(_) => {},
Err(ErrorKind::IoError(e)) => eprintln!("I/O Error: {:?}", e),
Err(_) => panic!("Unexpected error"),
}
Variants§
ContextLock
Failed to lock the context
ContextInconsistent
Context is inconsistent
ScopeNotInitialized
Log-Module isn’t initialized
KeyNotInitialized
Submodule is not initialized
ParseEnv
Parse environment variable failed
ParseArg
Parse commandline argument string failed
EnvType
Environment variable has unexpected type
UnknownLogLevel
Loglevel is unknown
WriteFailed
Failed to write logstring via Facade
InvalFmtString
Logging string contained non utf8 characters
LogCompatInitialized
Log Compat is already initialized
TaskLocal(TaskLocalErr)
Error in task local access
IoError(ErrorKind)
I/O Error while writing
Wraps the std::io::ErrorKind
thrown by the underlying I/O operation.