#[non_exhaustive]pub enum Error {
Show 17 variants
Open {
path: PathBuf,
source: Error,
},
Create {
path: PathBuf,
source: Error,
},
Write {
what: &'static str,
path: Option<PathBuf>,
source: Error,
},
Parse {
what: &'static str,
path: Option<PathBuf>,
source: Box<dyn Error + Send + Sync>,
},
Serialize {
what: &'static str,
source: Box<dyn Error + Send + Sync>,
},
WrongRoot {
what: &'static str,
expected: &'static str,
found: String,
},
MissingRoot {
what: &'static str,
},
MissingAttribute {
element: &'static str,
attribute: &'static str,
},
InvalidNumber {
context: &'static str,
value: String,
},
NonFiniteNumber {
context: &'static str,
value: String,
},
IncompletePosition {
context: &'static str,
value: String,
},
TooManyCoordinates {
context: &'static str,
value: String,
},
AmbiguousBool,
InvalidBoundary {
value: String,
},
InvalidColor {
value: String,
},
InvalidClockTime {
value: String,
},
ConflictingAttributes {
element: &'static str,
first: &'static str,
second: &'static str,
},
}Expand description
Anything that can go wrong reading or writing a SUMO file.
The variants split into three groups: I/O against the file itself,
well-formedness of the XML and its root element, and the SUMO-specific
value encodings each format’s schema_mapper interprets (positions,
shapes, booleans, …). Only the last group is specific to this crate;
the first two would apply to any XML reader.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Open
The input file could not be opened.
Create
The output file could not be created.
Write
Writing to the output failed partway through.
path is None when writing to a caller-supplied sink
(write_network_to and friends) rather than to a file this crate
opened itself. Code span, not an intra-doc link: this module is
compiled under every feature combination, and write_network_to
only exists under net + write — see the crate docs.
Parse
The document isn’t well-formed XML, or doesn’t fit the format’s schema.
The underlying error is boxed rather than named: it comes from
xsd-parser-types, which lib.rs deliberately keeps out of this
crate’s public API. std::error::Error::source still reaches it
for anyone who wants the detail.
Serialize
The value could not be serialized to XML. Boxed for the same reason
as Self::Parse.
WrongRoot
The document is well-formed but rooted at the wrong element — a
.rou.xml handed to read_network, say. (Code span rather than a
link, for the same reason as Self::Write above.)
Worth its own variant because nothing else catches it: xsd-parser
generates deserializers for XSD types, not elements, and most SUMO
schemas make their content optional, so an unrelated document
otherwise parses into an empty, plausible-looking value. See
xml::RootRecordingReader.
MissingRoot
The document has no root element at all (it is empty, or contains only a declaration and comments).
MissingAttribute
An attribute the format requires in practice was absent. Only raised
where a real SUMO writer always emits the attribute even though the
XSD marks it optional — see net::domain::Location.
InvalidNumber
A number didn’t parse. context names the attribute it came from
("junction x coordinate", …).
NonFiniteNumber
A number parsed but was NaN or an infinity, which SUMO’s
floatType pattern excludes and which would poison every
computation downstream — see sumo::parse_finite.
IncompletePosition
A position had fewer than the two coordinates SUMO’s positionType
requires.
TooManyCoordinates
A position had more than the three coordinates SUMO’s positionType
allows.
AmbiguousBool
SUMO’s boolType allows "x" and "-", the “unspecified” marker
its configuration options use. Neither has a binary meaning, so they
are an error rather than a silent false.
InvalidBoundary
A locationType boundary didn’t have exactly the four components
"minX,minY,maxX,maxY" needs.
InvalidColor
A colorType in its numeric form didn’t have 3 ("r,g,b") or 4
("r,g,b,a") components.
InvalidClockTime
A timeType in its clock form didn’t have 3 ("H:M:S") or 4
("H:M:S:MS") components.
ConflictingAttributes
Two attributes SUMO treats as alternatives were both set — an
e2Detector with both lane and lanes, for instance.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()