pub trait DisplaySourceError {
// Required methods
fn source_info(&self) -> SourceInfo;
fn description(&self) -> String;
fn fixme(&self, content: &[&str]) -> StyledString;
// Provided methods
fn message(&self, content: &[&str]) -> StyledString { ... }
fn render(
&self,
filename: &str,
content: &str,
entry_src_info: Option<SourceInfo>,
format: OutputFormat,
) -> String { ... }
}Required Methods§
fn source_info(&self) -> SourceInfo
fn description(&self) -> String
fn fixme(&self, content: &[&str]) -> StyledString
Provided Methods§
Sourcefn message(&self, content: &[&str]) -> StyledString
fn message(&self, content: &[&str]) -> StyledString
Returns the constructed message for the error
It may include:
- source line
- column position and number of characters (with one or more carets)
Examples:
GET abc
^ expecting http://, https:// or {{HTTP/1.0 200
^^^ actual value is <404>jsonpath "$.count" >= 5
actual: integer <2>
expected: greater than integer <5>{
"name": "John",
- "age": 27
+ "age": 28
}Sourcefn render(
&self,
filename: &str,
content: &str,
entry_src_info: Option<SourceInfo>,
format: OutputFormat,
) -> String
fn render( &self, filename: &str, content: &str, entry_src_info: Option<SourceInfo>, format: OutputFormat, ) -> String
Returns the string representation of an error, given lines of content and a filename.
The source information where the error occurred can be retrieved in error; optionally,
entry_src_info is the optional source information for the entry where the error happened.
If colored is true, the string use ANSI escape codes to add color and improve the readability
of the representation.
Example:
Assert status code | > description()
--> test.hurl:2:10 | > add_filename_with_sourceinfo()
| |
| GET http://foo.com | > add_entry_line()
| ... |
2 | HTTP/1.0 200 | > message()
| ^^^ actual value is <404> | >
| |