ul_next/
error.rs

1use std::string::FromUtf8Error;
2
3/// Errors can occure when creating some of the structs.
4#[derive(Debug, thiserror::Error)]
5pub enum CreationError {
6    /// Ultralight library returned null pointer, and couldn't create the
7    /// object.
8    #[error("Creation of an object failed because Ultralight returned a null pointer")]
9    NullReference,
10    /// Ultralight returned null pointer when trying to create an Ultralight string
11    /// from a Rust string.
12    #[error("Failed to convert the string {0} to an ultralight string")]
13    UlStringCreationError(String),
14    /// Ultralight string contained invalid UTF-8, and couldn't convert it to a
15    /// valid Rust string.
16    #[error("Failed to convert an ultralight string to Rust string")]
17    RustStringCreationError(#[from] FromUtf8Error),
18    /// `&str` contained a null byte, and couldn't convert it to a valid C string without losing data.
19    #[error("Failed to convert a rust `&str` to a C string")]
20    CStringCreationError(#[from] std::ffi::NulError),
21}