pub enum Error {
CargoMetadata(Error),
Command(&'static str, i32, bool),
Generic(String),
Io(Error),
Manifest(&'static str),
Mustache(Error),
Uuid(Error),
Version(Error),
Xml(Error),
XPath(ExecutionError),
}
Expand description
The error type for wix-related operations and associated traits.
Errors mostly originate from the dependencies, but custom instances of Error
can be created
with the Generic
variant and a message.
Variants§
CargoMetadata(Error)
Parsing of Cargo metadata failed.
Command(&'static str, i32, bool)
A command operation failed.
Generic(String)
A generic or custom error occurred. The message should contain the detailed information.
Io(Error)
An I/O operation failed.
Manifest(&'static str)
A needed field within the Cargo.toml
manifest could not be found.
Mustache(Error)
An error occurred with rendering the template using the mustache renderer.
Uuid(Error)
UUID generation or parsing failed.
Version(Error)
Parsing error for a version string or field.
Xml(Error)
Parsing the intermediate WiX Object (wixobj) file, which is XML, failed.
XPath(ExecutionError)
Evaluation of an XPath expression failed.
Implementations§
source§impl Error
impl Error
sourcepub fn code(&self) -> i32
pub fn code(&self) -> i32
Gets an error code related to the error.
Examples
use wix::Error;
let err = Error::from("A generic error");
assert_ne!(err.code(), 0)
This is useful as a return, or exit, code for a command line application, where a non-zero integer indicates a failure in the application. it can also be used for quickly and easily testing equality between two errors.
sourcepub fn already_exists(p: &Utf8Path) -> Self
pub fn already_exists(p: &Utf8Path) -> Self
Creates a new Error
from a std::io::Error with the
std::io::ErrorKind::AlreadyExists variant.
Examples
use std::io;
use camino::Utf8Path;
use wix::Error;
let path = Utf8Path::new("C:\\");
let expected = Error::Io(io::Error::new(
io::ErrorKind::AlreadyExists,
path.to_string()
));
assert_eq!(expected, Error::already_exists(path));
sourcepub fn not_found(p: &Path) -> Self
pub fn not_found(p: &Path) -> Self
Creates a new Error
from a std::io::Error with the
std::io::ErrorKind::NotFound variant.
Examples
use std::io;
use std::path::Path;
use wix::Error;
let path = Path::new("C:\\Cargo\\Wix\\file.txt");
let expected = Error::Io(io::Error::new(
io::ErrorKind::NotFound,
path.display().to_string()
));
assert_eq!(expected, Error::not_found(path));
sourcepub fn not_a_file(p: &Path) -> Self
pub fn not_a_file(p: &Path) -> Self
Creates a new Error
from a std::io::Error with the
std::io::ErrorKind::InvalidInput variant if a path is not a file.
Examples
use std::io;
use std::path::Path;
use wix::Error;
let path = Path::new("C:\\Cargo\\Wix\\file.txt");
let expected = Error::Io(io::Error::new(
io::ErrorKind::InvalidInput,
format!("The '{}' path is not a file.", path.display())
));
assert_eq!(expected, Error::not_a_file(path));
sourcepub fn not_a_manifest(p: &Path) -> Self
pub fn not_a_manifest(p: &Path) -> Self
Creates a new Error
from a std::io::Error with the
std::io::ErrorKind::InvalidInput variant if a path is not to a
Cargo.toml
file.
Examples
use std::io;
use std::path::Path;
use wix::Error;
let path = Path::new("C:\\Cargo\\Wix\\file.txt");
let expected = Error::Io(io::Error::new(
io::ErrorKind::InvalidInput,
format!(
"The '{}' path does not appear to be to a 'Cargo.toml' file.",
path.display(),
),
));
assert_eq!(expected, Error::not_a_manifest(path));
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Extracts a short, single word representation of the error.
The std::error::Error::description
method is “soft-deprecated”
according to the Rust stdlib documentation. It is recommended to use the
std::fmt::Display
implementation for a “description” string. However,
there is already a std::fmt::Display
implementation for this error
type, and it is nice to have a short, single word representation for
nicely formatting errors to humans. This method maintains the error
message formatting.