mirror of https://github.com/rwf2/Rocket.git
Update to yansi 0.3 for proper Debug formatting.
This commit also improves the format of TOML parsing error messages. Fixes #310.
This commit is contained in:
parent
3eeae77ed6
commit
504a7fe583
|
@ -22,5 +22,5 @@ log = "0.3"
|
|||
compiletest_rs = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
yansi = "0.2"
|
||||
yansi = "0.3"
|
||||
version_check = "0.1.2"
|
||||
|
|
|
@ -18,7 +18,7 @@ categories = ["web-programming::http-server"]
|
|||
tls = ["rustls", "hyper-rustls"]
|
||||
|
||||
[dependencies]
|
||||
yansi = "0.2"
|
||||
yansi = "0.3"
|
||||
log = "0.3"
|
||||
url = "1"
|
||||
toml = { version = "0.2", default-features = false }
|
||||
|
@ -47,5 +47,5 @@ lazy_static = "0.2"
|
|||
rocket_codegen = { version = "0.2.8", path = "../codegen" }
|
||||
|
||||
[build-dependencies]
|
||||
yansi = "0.2"
|
||||
yansi = "0.3"
|
||||
version_check = "0.1.2"
|
||||
|
|
|
@ -93,9 +93,9 @@ impl ConfigError {
|
|||
let (line, col) = error.start;
|
||||
let error_source = &source[lo..hi];
|
||||
|
||||
error!("config file could not be parsed as TOML");
|
||||
error!("config file failed to parse due to invalid TOML");
|
||||
info_!("at {:?}:{}:{}", White.paint(filename), line + 1, col + 1);
|
||||
trace_!("'{}' - {}", error_source, White.paint(&error.desc));
|
||||
trace_!("{:?} - {}", error_source, White.paint(&error.desc));
|
||||
}
|
||||
}
|
||||
BadEnvVal(ref key, ref value, ref error) => {
|
||||
|
|
|
@ -399,11 +399,18 @@ impl RocketConfig {
|
|||
let toml = parser.parse().ok_or_else(|| {
|
||||
let source = src.clone();
|
||||
let errors = parser.errors.iter()
|
||||
.map(|error| ParsingError {
|
||||
byte_range: (error.lo, error.hi),
|
||||
start: parser.to_linecol(error.lo),
|
||||
end: parser.to_linecol(error.hi),
|
||||
desc: error.desc.clone(),
|
||||
.map(|error| {
|
||||
// workaround for poor error messages `toml`
|
||||
let debug_desc = format!("{:?}", error.desc);
|
||||
// strip the leading " and trailing " from debug formatting
|
||||
let desc = debug_desc[1..debug_desc.len() - 1].to_string();
|
||||
|
||||
ParsingError {
|
||||
byte_range: (error.lo, error.hi),
|
||||
start: parser.to_linecol(error.lo),
|
||||
end: parser.to_linecol(error.hi),
|
||||
desc: desc
|
||||
}
|
||||
});
|
||||
|
||||
ConfigError::ParseError(source, path.clone(), errors.collect())
|
||||
|
|
Loading…
Reference in New Issue