diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-04 20:20:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-04 20:20:02 +0100 |
| commit | f72b1505bebf8d2fe1a60d386a3a3c3b67d4f903 (patch) | |
| tree | 09fa7137a2bae5454e6f9cecc1936633c90965d4 /src/layout | |
| parent | 9fb31defd037a90bf8f9e38fa33acae23a70b269 (diff) | |
Unify error types ♾
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/flex.rs | 3 | ||||
| -rw-r--r-- | src/layout/mod.rs | 21 | ||||
| -rw-r--r-- | src/layout/stack.rs | 3 | ||||
| -rw-r--r-- | src/layout/text.rs | 2 | ||||
| -rw-r--r-- | src/layout/tree.rs | 2 |
5 files changed, 8 insertions, 23 deletions
diff --git a/src/layout/flex.rs b/src/layout/flex.rs index 3e8a64e1..46d66951 100644 --- a/src/layout/flex.rs +++ b/src/layout/flex.rs @@ -230,7 +230,8 @@ impl FlexLayouter { while size.x > self.line.usable { if self.stack.space_is_last() { - lr!("box does not fit into line"); + error!("box of size {} does not fit into line of size {}", + size.x, self.line.usable); } self.stack.finish_space(true); diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 4304e46e..690e91b7 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -5,8 +5,8 @@ use std::io::{self, Write}; use smallvec::SmallVec; use toddle::query::{FontClass, SharedFontLoader}; -use toddle::Error as FontError; +use crate::TypesetResult; use crate::func::Command; use crate::size::{Size, Size2D, SizeBox}; use crate::style::{LayoutStyle, TextStyle}; @@ -366,22 +366,5 @@ impl Serialize for MultiLayout { } } -/// The error type for layouting. -pub struct LayoutError(String); - /// The result type for layouting. -pub type LayoutResult<T> = Result<T, LayoutError>; - -impl LayoutError { - /// Create a new layout error with a message. - pub fn new<S: Into<String>>(message: S) -> LayoutError { - LayoutError(message.into()) - } -} - -error_type! { - err: LayoutError, - show: f => f.write_str(&err.0), - from: (std::io::Error, LayoutError::new(err.to_string())), - from: (FontError, LayoutError::new(err.to_string())), -} +pub type LayoutResult<T> = TypesetResult<T>; diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 64823b67..176aa261 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -108,7 +108,8 @@ impl StackLayouter { // Find the first (sub-)space that fits the layout. while !self.sub.usable.fits(new_size) { if self.space_is_last() && self.space_is_empty() { - lr!("box does not fit into stack"); + error!("box of size {} does not fit into remaining stack of size {}", + size, self.sub.usable - Size2D::with_y(self.sub.size.y)); } self.finish_space(true); diff --git a/src/layout/text.rs b/src/layout/text.rs index 514bfe92..8a0e7cec 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -116,6 +116,6 @@ impl<'a, 'p> TextLayouter<'a, 'p> { self.classes.pop(); } - lr!("no suitable font for character `{}`", c); + error!("no suitable font for character `{}`", c); } } diff --git a/src/layout/tree.rs b/src/layout/tree.rs index 5fe3b6fd..c9d40e93 100644 --- a/src/layout/tree.rs +++ b/src/layout/tree.rs @@ -111,7 +111,7 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { SetTextStyle(style) => self.style.text = style, SetPageStyle(style) => { if !self.ctx.top_level { - lr!("page style cannot only be altered in the top-level context"); + error!("the page style cannot only be altered from a top-level context"); } self.style.page = style; |
