errors now emit sources
This commit is contained in:
parent
e27d218d2e
commit
3941e77f6a
4 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "oink"
|
name = "oink"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![feature(error_in_core)]
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use pico_args::Arguments;
|
use pico_args::Arguments;
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::{
|
||||||
io::Write,
|
io::Write,
|
||||||
path::Path
|
path::Path
|
||||||
};
|
};
|
||||||
|
use core::error::Error;
|
||||||
|
|
||||||
use toml::{ map::Map, Value };
|
use toml::{ map::Map, Value };
|
||||||
use tera::{ Context, Tera };
|
use tera::{ Context, Tera };
|
||||||
|
@ -66,7 +67,10 @@ pub fn build(targets: &Vec<Map<String, Value>>, tera: &mut Tera, context: &Conte
|
||||||
let render = tera.render(name, context);
|
let render = tera.render(name, context);
|
||||||
// handle rendering errors gracefully
|
// handle rendering errors gracefully
|
||||||
if render.is_err() {
|
if render.is_err() {
|
||||||
println!(" failed to render template");
|
let error = render.err().unwrap();
|
||||||
|
let message = error.source().unwrap();
|
||||||
|
|
||||||
|
println!(" failed to render template:\n {message}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue