#[non_exhaustive]pub enum WriteError {
MissingKey(RawStr),
TypeMismatch {
node: RawStr,
expected: &'static str,
},
OutOfRange {
node: RawStr,
},
NoRefTypes,
NoRefTypesAttribute,
RefTypeNotFound,
Malformed(RawStr),
NoTypeTree {
class_id: i32,
why: Option<NoTree>,
},
Tree(Box<ParseError>),
Limit(LimitError),
Charge(ChargeError),
}Expand description
Why writing a value failed (the dump’s L3 "error"). Each variant
stands for the exceptions Self::exceptions names, the classes UnityPy
1.25.2’s write_typetree raises there; a variant UnityPy has no
counterpart for names none.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingKey(RawStr)
A child name missing from the dict, or a ReferencedObject’s type
or one of its names (KeyError).
TypeMismatch
A value of the wrong type for its node. expected says what the node
takes, and which exception UnityPy raises: struct.error for int
and float; AttributeError for a str (value.encode), an
attribute, a ref type with a tree (None.m_MetaFlag) and a type
that is not a dict (getattr(typ, "class")); TypeError for
bytes, a sized iterable (len) and a ReferencedObject’s dict
(value[...]); TypeError, KeyError or IndexError for a
sequence of two (value[0] of an int, a dict or a short
sequence). A modelled attribute is the writer’s own refusal of a
dunder name, which UnityPy reads and may write (PARITY.md section
19.3).
OutOfRange
An integer outside its node’s width (struct.error), or a finite
float that overflows f32 (OverflowError).
NoRefTypes
ReferencedObject data with no assets file, or an empty ref_types
list (the writer raises where the reader does not; TypeTreeHelper.py:99-100):
ValueError.
NoRefTypesAttribute
ReferencedObject data against a file with no ref_types attribute
(RefTypes::Absent: a SerializedFile below format 20, which
UnityPy never sets it on, files/SerializedFile.py:306-308): reading
assetfile.ref_types raises AttributeError (TypeTreeHelper.py:99).
RefTypeNotFound
ReferencedObject data whose type is not in ref_types
(ValueError).
Malformed(RawStr)
A malformed node the writer reached: a pair’s or an Array’s
missing child (IndexError), or a matched ref type’s rows that make
no tree, which UnityPy refuses when it parses the file (an
IndexError too, TreeError).
NoTypeTree
The object has no tree to write with: UnityPy raises the same
exception for a write as for a read (files/ObjectReader.py:264-307;
the read side’s ParseError::NoTypeTree).
Tree(Box<ParseError>)
Resolving the object’s tree failed (a tree that does not compile, a provider’s failure): the writer never ran.
Limit(LimitError)
A bound from Limits.
Charge(ChargeError)
The input’s meter or the budget refused the output’s memory.
Implementations§
Source§impl WriteError
impl WriteError
Sourcepub fn exceptions(&self) -> &'static [&'static str]
pub fn exceptions(&self) -> &'static [&'static str]
The classes, by __name__ (error is struct.error), of the
exceptions UnityPy 1.25.2’s write_typetree (TypeTreeHelper.py:407-458
and streams/EndianBinaryWriter.py) raises where the writer reports
this error, as the variants’ docs give them; tests/walk_fixtures.rs
checks against this every raise in the cases, the value cases and
W2’s matrix tools/fixtures/walk.py records.
None for an error UnityPy has no counterpart for: a bound of
Limits or a refused charge (PARITY.md section 19.3), a dunder
attribute (Self::TypeMismatch), and a tree that failed before the
writer ran (Self::Tree: the read side’s error); a
Self::NoTypeTree with no why says nothing of UnityPy’s.
Trait Implementations§
Source§impl Clone for WriteError
impl Clone for WriteError
Source§impl Debug for WriteError
impl Debug for WriteError
Source§impl Display for WriteError
impl Display for WriteError
impl Eq for WriteError
Source§impl Error for WriteError
impl Error for WriteError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()