use std::process;
use crate::parser::BuildVars;
pub struct KeyTreeErr;
impl KeyTreeErr {
pub fn append_path(_vars: &BuildVars) {
let s = "Tried to call at() on .. but failed to append path.";
println!("{}", s);
process::exit(1);
}
pub fn at_on_empty(_vars: &BuildVars) {
let s = format!(
"Tried to call at() on a non-existent path.",
);
println!("{}", s);
process::exit(1);
}
pub fn colon_before_key(pos: usize) {
let s = format!(
"Expected a character to start a key but received a colon at pos: {}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn char_after_value(pos: usize) {
let s = format!(
"char after value at pos: {}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn empty_string() {
let s = format!(
"Could not parse empty string."
);
println!("{}", s);
process::exit(1);
}
pub fn first_token_is_val(pos: usize, _vars: &BuildVars) {
let s = format!(
"Tried to parse string and expected first token to be a key, but it was a value at ps: {:?}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn indent(pos: usize, vars: &BuildVars) {
let s = format!(
"Tried to parse string but key must be indent in units of 4 at pos: {}.",
pos
);
println!("{}", vars.s);
println!("{}", s);
process::exit(1);
}
pub fn line_incomplete(pos: usize) {
let s = format!("Tried to parse line, but the line was incomplete error at pos: {}.", pos);
println!("{}", s);
process::exit(1);
}
pub fn missing_quote(pos: usize) {
let s = format!(
"missing quote at start of value at pos: {}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn no_colon(pos: usize) {
let s = format!(
"Tried to parse a key but there was a whitespace but not colon at: {}.",
pos,
);
println!("{}", s);
process::exit(1);
}
pub fn no_space_after_key(pos: usize) {
let s = format!(
"Tried to parse a key but there was no space after the colon at: {}.",
pos,
);
println!("{}", s);
process::exit(1);
}
pub fn no_value() {
let s = format!("Expected a value but couldn't find it.");
println!("{}", s);
process::exit(1);
}
pub fn non_contiguous() {
let s = format!(
"A key appears in a non-contiguous position."
);
println!("{}", s);
process::exit(1);
}
pub fn not_keyval() {
let s = format!(
"The token is not a key/value."
);
println!("{}", s);
process::exit(1);
}
pub fn not_unique() {
let s = "expected a unique path when calling value() on KeyTree, using context path.";
println!("{}", s);
process::exit(1);
}
pub fn not_unique_but_empty() {
let s = "expected a unique path but found and empty path.";
println!("{}", s);
process::exit(1);
}
pub fn not_unique_but_many() {
let s = "expected a unique path but found several paths.";
println!("{}", s);
process::exit(1);
}
pub fn not_value() {
let s = "tried to call value() on KeyTree but the token at the context path was a Key.";
println!("{}", s);
process::exit(1);
}
pub fn parse_keytree() {
let s = "Failed to parse string.";
println!("{}", s);
process::exit(1);
}
pub fn parse_value() {
let s = format!(
"Tried to parse a value, but failed."
);
println!("{}", s);
process::exit(1);
}
pub fn path_not_in_keymap() {
let s = "tried to find text path in KeyTree but was not in KeyMap.";
println!("{}", s);
process::exit(1);
}
pub fn path_not_in_keylen() {
let s = format!(
"Tried to find path in KeyLen but was missing.",
);
println!("{}", s);
process::exit(1);
}
pub fn quote_in_key(pos: usize) {
let s = format!(
"quote in key at pos: {}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn path(pos: usize) {
let s = format!(
"path parsing error at pos: {}.",
pos
);
println!("{}", s);
process::exit(1);
}
pub fn root_key() {
let s = format!(
"could not get root key."
);
println!("{}", s);
process::exit(1);
}
}