DisplaySourceError

Trait DisplaySourceError 

Source
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§

Source

fn source_info(&self) -> SourceInfo

Source

fn description(&self) -> String

Source

fn fixme(&self, content: &[&str]) -> StyledString

Provided Methods§

Source

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
}
Source

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>    | >
  |                                       |

Implementors§