diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-11-30 14:10:35 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-11-30 14:10:35 +0100 |
| commit | b13ed627fff73a599b34d760cd99aa2f08d58ea8 (patch) | |
| tree | f580390e1666af9f4f54c72c95ca438d4c999900 /src/layout/tree.rs | |
| parent | b4efae08834a3a950387f01aebaa9e832acd9423 (diff) | |
Better error reporting 🚨
Diffstat (limited to 'src/layout/tree.rs')
| -rw-r--r-- | src/layout/tree.rs | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/src/layout/tree.rs b/src/layout/tree.rs index f5ae2435..56fb120c 100644 --- a/src/layout/tree.rs +++ b/src/layout/tree.rs @@ -66,34 +66,20 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { } fn layout_func(&mut self, func: &FuncCall) -> LayoutResult<()> { - let (first, second) = self.flex.remaining()?; + let spaces = self.flex.remaining(); let mut axes = self.ctx.axes.expanding(false); axes.secondary.alignment = Alignment::Origin; - let ctx = |spaces| { - LayoutContext { - loader: self.ctx.loader, - top_level: false, - text_style: &self.style, - page_style: self.ctx.page_style, - spaces, - axes, - expand: false, - } - }; - - let commands = match func.body.val.layout(ctx(first)) { - Ok(c) => c, - Err(e) => { - match (e, second) { - (LayoutError::NotEnoughSpace(_), Some(space)) => { - func.body.val.layout(ctx(space))? - } - (e, _) => Err(e)?, - } - } - }; + let commands = func.body.val.layout(LayoutContext { + loader: self.ctx.loader, + top_level: false, + text_style: &self.style, + page_style: self.ctx.page_style, + spaces, + axes, + expand: false, + })?; for command in commands { self.execute(command)?; @@ -123,7 +109,7 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { Command::SetTextStyle(style) => self.style = style, Command::SetPageStyle(style) => { if !self.ctx.top_level { - Err(LayoutError::Unallowed("can only set page style from top level"))?; + lerr!("page style cannot only be altered in the top-level context"); } self.ctx.page_style = style; |
