Skip to content

Commit

Permalink
Merge pull request #29 from axodotdev/opt-label
Browse files Browse the repository at this point in the history
use options for labels
  • Loading branch information
ashleygwilliams authored Apr 4, 2023
2 parents 2b8825e + c9962be commit e33448f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub enum AxoassetError {
source: crate::SourceFile,
/// The range the error was found on
#[label]
span: miette::SourceSpan,
span: Option<miette::SourceSpan>,
/// Details of the error
#[source]
details: serde_json::Error,
Expand All @@ -291,7 +291,7 @@ pub enum AxoassetError {
source: crate::SourceFile,
/// The range the error was found on
#[label]
span: miette::SourceSpan,
span: Option<miette::SourceSpan>,
/// Details of the error
#[source]
details: toml::de::Error,
Expand Down
7 changes: 2 additions & 5 deletions src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ impl SourceFile {
#[cfg(feature = "json-serde")]
pub fn deserialize_json<'a, T: serde::Deserialize<'a>>(&'a self) -> Result<T> {
let json = serde_json::from_str(self.source()).map_err(|details| {
let span = self
.span_for_line_col(details.line(), details.column())
.unwrap_or((0..0).into());
let span = self.span_for_line_col(details.line(), details.column());
AxoassetError::Json {
source: self.clone(),
span,
Expand All @@ -99,8 +97,7 @@ impl SourceFile {
let toml = toml::from_str(self.source()).map_err(|details| {
let span = details
.line_col()
.and_then(|(line, col)| self.span_for_line_col(line, col))
.unwrap_or((0..0).into());
.and_then(|(line, col)| self.span_for_line_col(line, col));
AxoassetError::Toml {
source: self.clone(),
span,
Expand Down

0 comments on commit e33448f

Please sign in to comment.