errors now emit sources

This commit is contained in:
Valerie Wolfe 2023-08-16 12:53:54 -04:00
parent e27d218d2e
commit 3941e77f6a
4 changed files with 11 additions and 2 deletions

View file

@ -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
View file

@ -0,0 +1,4 @@
[toolchain]
channel = "nightly"

View file

@ -1,3 +1,4 @@
#![feature(error_in_core)]
use std::process::exit; use std::process::exit;
use pico_args::Arguments; use pico_args::Arguments;

View file

@ -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;
} }