Skip to content

Commit

Permalink
Refacto error_string in order to support diff messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricereix committed Apr 4, 2024
1 parent c8c3cf4 commit 43863eb
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 97 deletions.
4 changes: 2 additions & 2 deletions integration/hurl/tests_failed/assert_newline.err
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ error: Assert body value
| ...
10 | <p>Hello</p>
| ^ actual value is <<p>Hello</p>

>
|
| >
|

12 changes: 10 additions & 2 deletions packages/hurl/src/runner/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ impl hurl_core::error::Error for Error {
..
} => {
let additional = if *type_mismatch {
"\n>>> types between actual and expected are not consistent"
"\n >>> types between actual and expected are not consistent"
} else {
""
};
format!("actual: {actual}\nexpected: {expected}{additional}")
format!(" actual: {actual}\n expected: {expected}{additional}")
}
RunnerError::AssertHeaderValueError { actual } => {
format!("actual value is <{actual}>")
Expand Down Expand Up @@ -257,6 +257,14 @@ impl hurl_core::error::Error for Error {
}
}
}

fn show_source_line(&self) -> bool {
true
}

fn show_caret(&self) -> bool {
!matches!(&self.inner, RunnerError::AssertFailure { .. })
}
}

impl From<HttpError> for RunnerError {
Expand Down
Loading

0 comments on commit 43863eb

Please sign in to comment.