Enum wix::Error

source ·
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

source

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.

source

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));
source

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));
source

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));
source

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));
source

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.

Trait Implementations§

source§

impl Debug for Error

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Error

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for Error

source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
source§

fn source(&self) -> Option<&(dyn StdError + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, demand: &mut Demand<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<'a> From<&'a str> for Error

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(err: Error) -> Self

Converts to this type from the input type.
source§

impl From<ExecutionError> for Error

source§

fn from(err: ExecutionError) -> Self

Converts to this type from the input type.
source§

impl From<StripPrefixError> for Error

source§

fn from(err: StripPrefixError) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Error> for Error

source§

fn eq(&self, other: &Error) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<E> Provider for Ewhere E: Error + ?Sized,

source§

fn provide<'a>(&'a self, demand: &mut Demand<'a>)

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.