Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ edition = "2018"
all-features = true

[features]
default = ["serde_yaml", "serde_json", "colored", "graphemes_support", "toml"]
default = ["serde_yaml", "serde_json", "colored", "graphemes_support", "toml", "ron"]
graphemes_support = ["unicode-segmentation"]

[dependencies]
Expand All @@ -30,6 +30,7 @@ serde = { version = "1", features = ["derive"] }
serde_yaml = { version = "0.8", optional = true }
unicode-segmentation = { version = "1", optional = true }
toml = { version = "0.5", optional = true }
ron = { version = "0.8", optional = true }

[dev-dependencies]
anyhow = "1"
Expand Down
32 changes: 20 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ use colored::Colorize;

use std::{
fmt,
sync::atomic::{
AtomicBool,
AtomicUsize,
Ordering,
},
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};

#[cfg(feature = "colored")]
Expand All @@ -134,13 +130,7 @@ mod control;
mod test;

#[cfg(feature = "colored")]
pub use control::{
always_color,
never_color,
set_coloring_mode,
use_environment,
ColoringMode,
};
pub use control::{always_color, never_color, set_coloring_mode, use_environment, ColoringMode};

/// If the output should be contextualized or not.
pub const CONTEXTUALIZE_DEFAULT: bool = true;
Expand Down Expand Up @@ -232,6 +222,10 @@ pub enum ErrorTypes {
/// Contains [`toml::de::Error`].
Toml(toml::de::Error),

#[cfg(feature = "ron")]
/// Contains [`ron::de::Error`].
Ron(ron::error::SpannedError),

/// Used for custom errors that don't come from serde_yaml or
/// serde_json.
Custom {
Expand Down Expand Up @@ -273,6 +267,13 @@ impl From<toml::de::Error> for ErrorTypes {
}
}

#[cfg(feature = "ron")]
impl From<ron::de::SpannedError> for ErrorTypes {
fn from(err: ron::de::SpannedError) -> Self {
Self::Ron(err)
}
}

impl From<(Box<dyn std::error::Error>, Option<usize>, Option<usize>)> for ErrorTypes {
fn from(value: (Box<dyn std::error::Error>, Option<usize>, Option<usize>)) -> Self {
Self::Custom {
Expand Down Expand Up @@ -313,6 +314,13 @@ impl SerdeError {
Some((line, column)) => (e.to_string(), Some(line + 1), Some(column)),
},

#[cfg(feature = "ron")]
ErrorTypes::Ron(e) => (
e.code.to_string(),
Some(e.position.line),
Some(e.position.col),
),

ErrorTypes::Custom {
error,
line,
Expand Down