Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Frazer <joseph.frazer@ryansg.com>2020-03-07 10:28:39 -0500
committerJoseph Frazer <joseph.frazer@ryansg.com>2020-03-09 08:23:13 -0400
commit2a5551a04a6705d20e16c54aca1f875198ae89ab (patch)
treebe52192003e7e6dcaa8b70351633c14b1b23a6c7 /tamer/src/ld/poc.rs
parent06bc89a9cee68a242dfd91497c1c7ab36ac30424 (diff)
downloadtame-2a5551a04a6705d20e16c54aca1f875198ae89ab.tar.gz
tame-2a5551a04a6705d20e16c54aca1f875198ae89ab.tar.bz2
tame-2a5551a04a6705d20e16c54aca1f875198ae89ab.zip
[DEV-7134] Propagate errors setting fragments
If we cannot set a fragment, we need to display the error to the user. We are currently ignoring "___head", "___tail", and objects that are both virtual and overridden. Those will be corrected in with future changes.
Diffstat (limited to 'tamer/src/ld/poc.rs')
-rw-r--r--tamer/src/ld/poc.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/tamer/src/ld/poc.rs b/tamer/src/ld/poc.rs
index 6bedd7a..6d3d175 100644
--- a/tamer/src/ld/poc.rs
+++ b/tamer/src/ld/poc.rs
@@ -21,8 +21,7 @@
//! banished to its own file to try to make that more clear.
use crate::global;
-use crate::ir::asg::IdentKind;
-use crate::ir::asg::{Asg, DefaultAsg, Object, ObjectRef, Source};
+use crate::ir::asg::{Asg, DefaultAsg, IdentKind, Object, ObjectRef, Source};
use crate::obj::xmle::writer::{Sections, XmleWriter};
use crate::obj::xmlo::reader::{XmloError, XmloEvent, XmloReader};
use crate::sym::{DefaultInterner, Interner, Symbol};
@@ -187,16 +186,17 @@ fn load_xmlo<'a, 'i, I: Interner<'i>>(
}
Ok(XmloEvent::Fragment(sym, text)) => {
- let result = depgraph.set_fragment(
- depgraph.lookup(sym).unwrap_or_else(|| {
- panic!("missing symbol for fragment: {}", sym)
- }),
- text,
- );
-
- match result {
- Ok(_) => (),
- Err(e) => println!("{:?}; skipping...", e),
+ match depgraph.lookup(sym) {
+ Some(frag) => match depgraph.set_fragment(frag, text) {
+ Ok(_) => (),
+ Err(e) => return Err(e.into()),
+ },
+ None => {
+ return Err(XmloError::MissingFragment(String::from(
+ "missing fragment",
+ ))
+ .into());
+ }
};
}