mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-23 00:44:55 +03:00
Rename Error trait to DisplaySourceError
This commit is contained in:
parent
db2d5359cd
commit
4615283e9b
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
use crate::runner;
|
||||
use hurl_core::error::Error as CoreError;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -19,6 +19,7 @@ use colored::Colorize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
|
||||
use crate::http::{HttpError, RequestedHttpVersion};
|
||||
|
||||
@ -119,7 +120,7 @@ pub enum RunnerError {
|
||||
}
|
||||
|
||||
/// Textual Output for runner errors
|
||||
impl hurl_core::error::Error for Error {
|
||||
impl DisplaySourceError for Error {
|
||||
fn source_info(&self) -> SourceInfo {
|
||||
self.source_info
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ use std::time::Instant;
|
||||
use chrono::Utc;
|
||||
use hurl_core::ast::VersionValue::VersionAnyLegacy;
|
||||
use hurl_core::ast::{Body, Bytes, Entry, MultilineString, Request, Response, Retry};
|
||||
use hurl_core::error::Error;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
use hurl_core::parser;
|
||||
|
||||
use crate::http::{Call, Client};
|
||||
|
@ -19,7 +19,7 @@ use std::cmp::max;
|
||||
|
||||
use colored::*;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
|
||||
use crate::runner::Value;
|
||||
use crate::util::term::Stderr;
|
||||
@ -224,7 +224,12 @@ impl Logger {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug_error<E: Error>(&mut self, content: &str, error: &E, entry_src_info: SourceInfo) {
|
||||
pub fn debug_error<E: DisplaySourceError>(
|
||||
&mut self,
|
||||
content: &str,
|
||||
error: &E,
|
||||
entry_src_info: SourceInfo,
|
||||
) {
|
||||
if self.verbosity.is_none() {
|
||||
return;
|
||||
}
|
||||
@ -300,12 +305,12 @@ impl Logger {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_parsing_rich<E: Error>(&mut self, content: &str, error: &E) {
|
||||
pub fn error_parsing_rich<E: DisplaySourceError>(&mut self, content: &str, error: &E) {
|
||||
let message = error_string(&self.filename, content, error, None, self.color);
|
||||
self.error_rich(&message);
|
||||
}
|
||||
|
||||
pub fn error_runtime_rich<E: Error>(
|
||||
pub fn error_runtime_rich<E: DisplaySourceError>(
|
||||
&mut self,
|
||||
content: &str,
|
||||
error: &E,
|
||||
@ -388,7 +393,7 @@ impl Stderr {
|
||||
/// | ^^^ actual value is <404>
|
||||
/// |
|
||||
/// ```
|
||||
pub(crate) fn error_string<E: Error>(
|
||||
pub(crate) fn error_string<E: DisplaySourceError>(
|
||||
filename: &str,
|
||||
content: &str,
|
||||
error: &E,
|
||||
@ -512,7 +517,7 @@ pub(crate) fn error_string<E: Error>(
|
||||
///+ "age": 28
|
||||
/// }
|
||||
///
|
||||
fn get_message<E: Error>(error: &E, lines: &[&str], colored: bool) -> String {
|
||||
fn get_message<E: DisplaySourceError>(error: &E, lines: &[&str], colored: bool) -> String {
|
||||
let mut text = String::new();
|
||||
|
||||
if error.show_source_line() {
|
||||
@ -746,7 +751,7 @@ HTTP 200
|
||||
"#;
|
||||
let filename = "test.hurl";
|
||||
struct E;
|
||||
impl Error for E {
|
||||
impl DisplaySourceError for E {
|
||||
fn source_info(&self) -> SourceInfo {
|
||||
SourceInfo::new(Pos::new(4, 1), Pos::new(4, 0))
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
use crate::ast::SourceInfo;
|
||||
|
||||
pub trait Error {
|
||||
pub trait DisplaySourceError {
|
||||
fn source_info(&self) -> SourceInfo;
|
||||
fn description(&self) -> String;
|
||||
fn fixme(&self, content: &[&str], color: bool) -> String;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::{Pos, SourceInfo};
|
||||
use crate::error::DisplaySourceError;
|
||||
use colored::Colorize;
|
||||
use std::cmp;
|
||||
|
||||
@ -89,7 +90,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::error::Error for Error {
|
||||
impl DisplaySourceError for Error {
|
||||
fn source_info(&self) -> SourceInfo {
|
||||
SourceInfo {
|
||||
start: self.pos,
|
||||
|
@ -19,7 +19,7 @@ use std::path::PathBuf;
|
||||
|
||||
use crate::linter;
|
||||
use colored::*;
|
||||
use hurl_core::error::Error;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
use hurl_core::parser;
|
||||
|
||||
pub fn make_logger_verbose(verbose: bool) -> impl Fn(&str) {
|
||||
@ -78,7 +78,7 @@ fn log_error(
|
||||
lines: Vec<String>,
|
||||
color: bool,
|
||||
filename: Option<PathBuf>,
|
||||
error: &dyn Error,
|
||||
error: &dyn DisplaySourceError,
|
||||
warning: bool,
|
||||
) {
|
||||
let line_number_size = if lines.len() < 100 {
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
use hurl_core::error::DisplaySourceError;
|
||||
|
||||
use crate::linter;
|
||||
use crate::linter::LinterError;
|
||||
@ -24,7 +24,7 @@ use crate::linter::LinterError;
|
||||
///
|
||||
/// Textual Output for linter errors
|
||||
///
|
||||
impl Error for linter::Error {
|
||||
impl DisplaySourceError for linter::Error {
|
||||
fn source_info(&self) -> SourceInfo {
|
||||
self.source_info
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user