Replaced zutil-app-error with app-error.

This commit is contained in:
Filipe Rodrigues 2025-09-14 00:16:03 +01:00
parent ed74a8c32d
commit 2f07a97293
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
18 changed files with 47 additions and 47 deletions

18
Cargo.lock generated
View File

@ -82,6 +82,14 @@ version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/Zenithsiz/app-error?rev=9a7c202f54ef449d02e2b6ace74ad916f6e6720e#9a7c202f54ef449d02e2b6ace74ad916f6e6720e"
dependencies = [
"itertools",
]
[[package]]
name = "async-broadcast"
version = "0.7.2"
@ -2006,6 +2014,7 @@ dependencies = [
name = "zbuild"
version = "0.1.10"
dependencies = [
"app-error",
"async-broadcast",
"clap",
"console-subscriber",
@ -2027,7 +2036,6 @@ dependencies = [
"tracing-test",
"unicode-ident",
"yoke",
"zutil-app-error",
]
[[package]]
@ -2055,11 +2063,3 @@ name = "zerofrom"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
[[package]]
name = "zutil-app-error"
version = "0.1.0"
source = "git+https://github.com/Zenithsiz/zutil?rev=5363bba6ced162185a1eb5a132cce499bfc5d818#5363bba6ced162185a1eb5a132cce499bfc5d818"
dependencies = [
"itertools",
]

View File

@ -9,6 +9,7 @@ publish = ["filipejr"]
[dependencies]
app-error = { git = "https://github.com/Zenithsiz/app-error", rev = "9a7c202f54ef449d02e2b6ace74ad916f6e6720e" }
async-broadcast = "0.7.2"
clap = { features = ["derive"], version = "4.5.47" }
console-subscriber = { optional = true, version = "0.4.1" }
@ -28,7 +29,6 @@ tracing-log = "0.2.0"
tracing-subscriber = { features = ["env-filter"], version = "0.3.20" }
unicode-ident = "1.0.19"
yoke = "0.8.0"
zutil-app-error = { git = "https://github.com/Zenithsiz/zutil", rev = "5363bba6ced162185a1eb5a132cce499bfc5d818" }
[dev-dependencies]

View File

@ -9,8 +9,8 @@
// Imports
use {
crate::{AppError, util::ArcStr},
app_error::Context,
std::{fmt::Write, fs, mem, path::Path, ptr, str::pattern::Pattern},
zutil_app_error::Context,
};
/// Zbuild ast
@ -242,19 +242,19 @@ impl Parsable for Command {
{
AnyOf3::T0(_) => {
parser.parse::<TokenCwd>()?;
zutil_app_error::ensure!(cwd.is_none(), "Working directory was already specified");
app_error::ensure!(cwd.is_none(), "Working directory was already specified");
cwd = Some(parser.parse::<Expr>()?);
parser.parse::<TokenSemi>()?;
},
AnyOf3::T1(_) => {
parser.parse::<TokenStdout>()?;
zutil_app_error::ensure!(stdout.is_none(), "Stdout was already specified");
app_error::ensure!(stdout.is_none(), "Stdout was already specified");
stdout = Some(parser.parse::<Ident>()?);
parser.parse::<TokenSemi>()?;
},
AnyOf3::T2(_) => {
parser.parse::<TokenArgs>()?;
zutil_app_error::ensure!(args.is_none(), "Arguments were already specified");
app_error::ensure!(args.is_none(), "Arguments were already specified");
args = Some(parser.parse::<Array<Expr>>()?);
parser.parse::<TokenSemi>()?;
},
@ -404,7 +404,7 @@ impl ExprCmpt {
let op = parser.parse::<Ident>().context("Expected identifier after `.`")?;
match &*op.0 {
"dir_name" => ops.push(ExprOp::DirName),
op => zutil_app_error::bail!("Unknown expression operator: {op:?}"),
op => app_error::bail!("Unknown expression operator: {op:?}"),
}
}
@ -415,7 +415,7 @@ impl ExprCmpt {
parser.parse::<TokenDoubleQuote>()?;
while parser.try_parse::<TokenDoubleQuote>().is_err() {
let Some(end_idx) = parser.remaining().find(['{', '"']) else {
zutil_app_error::bail!("Expected closing `\"` after `\"`");
app_error::bail!("Expected closing `\"` after `\"`");
};
let prefix = parser.advance_by(end_idx);
if !prefix.is_empty() {
@ -489,7 +489,7 @@ pub macro decl_tokens($($TokenName:ident = $Token:expr;)*) {
fn parse_from(parser: &mut Parser) -> Result<Self, AppError> {
match parser.strip_prefix($Token) {
Some(value) => Ok(Self(value.into())),
None => zutil_app_error::bail!("Expected {:?}", $Token),
None => app_error::bail!("Expected {:?}", $Token),
}
}
}
@ -742,7 +742,7 @@ macro decl_any_of($Name:ident, $($T:ident),* $(,)?) {
}.expect("Failed to write into string");
)*
Err(zutil_app_error::AppError::msg(err))
Err(app_error::AppError::msg(err))
}
}
}

View File

@ -26,7 +26,7 @@ use {
smallvec::SmallVec,
std::{collections::HashMap, fmt, future::Future, process::Stdio, sync::Arc, time::SystemTime},
tokio::{fs, io::AsyncReadExt, process, sync::Semaphore, task},
zutil_app_error::{AllErrs, Context, app_error},
app_error::{AllErrs, Context, app_error},
};
/// Event
@ -691,7 +691,7 @@ impl Builder {
errs.into_iter().map(|(_, err)| Err(err)).collect::<AllErrs<(), _>>()?;
// If no errors existed, return an error for that
zutil_app_error::bail!("Dependencies file {deps_file:?} had no dependencies");
app_error::bail!("Dependencies file {deps_file:?} had no dependencies");
},
// Otherwise, just log and remove all errors

View File

@ -5,7 +5,7 @@ use {
crate::{AppError, rules::Target, util::ArcStr},
itertools::Itertools,
std::{ops::Try, sync::Arc},
zutil_app_error::app_error,
app_error::app_error,
};
/// Inner type for [`BuildReason`].

View File

@ -8,7 +8,7 @@ use std::{
};
/// App error
pub type AppError = zutil_app_error::AppError<AppErrorData>;
pub type AppError = app_error::AppError<AppErrorData>;
/// App error data
#[derive(Clone, Copy, Debug)]
@ -59,6 +59,6 @@ impl FromResidual<Yeet<AppError>> for ExitResult {
}
/// Function to setup pretty printing
pub fn pretty(err: &AppError) -> zutil_app_error::PrettyDisplay<'_, AppErrorData> {
pub fn pretty(err: &AppError) -> app_error::PrettyDisplay<'_, AppErrorData> {
err.pretty().with_ignore_err(|_, data| data.should_ignore)
}

View File

@ -9,7 +9,7 @@ use {
},
smallvec::SmallVec,
std::{collections::HashMap, mem, path::PathBuf},
zutil_app_error::{AllErrs, Context, app_error},
app_error::{AllErrs, Context, app_error},
};
/// Expander
@ -67,7 +67,7 @@ impl Expander {
// Else keep on Keep and error on Error
FlowControl::Keep => expr.push(cmpt),
FlowControl::Error => zutil_app_error::bail!("Unknown expression {name:?}"),
FlowControl::Error => app_error::bail!("Unknown expression {name:?}"),
},
}
@ -84,7 +84,7 @@ impl Expander {
ExprOp::DirName => {
// Get the path and try to pop the last segment
let mut path = PathBuf::from(mem::take(value));
zutil_app_error::ensure!(path.pop(), "Path had no parent directory {path:?}");
app_error::ensure!(path.pop(), "Path had no parent directory {path:?}");
// Then convert it back to a string
// Note: This should technically never fail, since the path was originally

View File

@ -66,7 +66,7 @@ use {
},
util::ArcStr,
watcher::Watcher,
zutil_app_error::Context,
app_error::Context,
};
#[expect(clippy::too_many_lines, reason = "TODO: Split it up more")]
@ -257,7 +257,7 @@ async fn find_zbuild() -> Result<PathBuf, AppError> {
true => return Ok(zbuild_path),
false => match cur_path.parent() {
Some(parent) => cur_path = parent,
None => zutil_app_error::bail!(
None => app_error::bail!(
"No `zbuild.zb` file found in current or parent directories.\nYou can use `--path \
{{zbuild-path}}` in order to specify the manifest's path"
),

View File

@ -28,6 +28,7 @@ mod logger;
// Imports
use {
self::logger::Logger,
app_error::Context,
clap::Parser,
std::{
env,
@ -35,7 +36,6 @@ use {
},
tokio::runtime,
zbuild::{Args, ExitResult},
zutil_app_error::Context,
};
#[expect(

View File

@ -69,7 +69,7 @@ impl<K> ExprTree<K> {
// After this the expression should be empty
if let Some(cmpt) = cmpts.next() {
zutil_app_error::bail!("Unexpected component in expression {expr}: {cmpt}");
app_error::bail!("Unexpected component in expression {expr}: {cmpt}");
}
// Finally try to insert and retrieve the old key, if any.

View File

@ -25,8 +25,8 @@ impl OutItem<Expr> {
/// Creates a new item from it's `ast`.
pub fn from_ast(item: ast::Expr) -> Result<Self, AppError> {
let is_deps_file = item.is_deps_file;
zutil_app_error::ensure!(!item.is_opt, "Output items cannot be optional");
zutil_app_error::ensure!(!item.is_static, "Output items cannot be static");
app_error::ensure!(!item.is_opt, "Output items cannot be optional");
app_error::ensure!(!item.is_static, "Output items cannot be static");
Ok(Self::File {
file: Expr::from_ast(item),

View File

@ -20,7 +20,7 @@ use {
},
tokio::sync::mpsc,
tokio_stream::wrappers::ReceiverStream,
zutil_app_error::Context,
app_error::Context,
};
/// A reverse dependency

View File

@ -9,7 +9,7 @@ mod util;
// Imports
use {
zbuild::ExitResult,
zutil_app_error::{Context, app_error},
app_error::{Context, app_error},
};
/// Single rule with multiple outputs

View File

@ -9,7 +9,7 @@ mod util;
// Imports
use {
zbuild::ExitResult,
zutil_app_error::{Context, app_error},
app_error::{Context, app_error},
};
/// Single rule and target

View File

@ -9,7 +9,7 @@ mod util;
// Imports
use {
zbuild::ExitResult,
zutil_app_error::{Context, app_error},
app_error::{Context, app_error},
};
/// Single rule and target

View File

@ -11,7 +11,7 @@ use {
std::fs,
tempfile::TempDir,
zbuild::{Args, ExitResult},
zutil_app_error::Context,
app_error::Context,
};
#[tokio::test]
@ -41,11 +41,11 @@ rule a {
};
tracing::info!(?args, "Arguments");
let res = zbuild::run(args).await;
zutil_app_error::ensure!(res.is_err(), "Expected zbuild error");
app_error::ensure!(res.is_err(), "Expected zbuild error");
let a = temp_dir.path().join("a");
zutil_app_error::ensure!(
app_error::ensure!(
!a.try_exists().context("Unable to check if output file exists")?,
"Output file {a:?} was created when it shouldn't've"
);

View File

@ -11,7 +11,7 @@ use {
std::fs,
tempfile::TempDir,
zbuild::{AppError, Args, ExitResult},
zutil_app_error::Context,
app_error::Context,
};
/// Test for `--keep-going`
@ -92,34 +92,34 @@ rule c2 {
};
tracing::info!(?args, "Arguments");
let res = zbuild::run(args).await;
zutil_app_error::ensure!(res.is_err(), "Expected zbuild error");
app_error::ensure!(res.is_err(), "Expected zbuild error");
let a = temp_dir.path().join("a");
let b = temp_dir.path().join("b");
let c1 = temp_dir.path().join("c1");
let c2 = temp_dir.path().join("c2");
zutil_app_error::ensure!(
app_error::ensure!(
!a.try_exists().context("Unable to check if output file exists")?,
"Output file {a:?} was created"
);
zutil_app_error::ensure!(
app_error::ensure!(
!b.try_exists().context("Unable to check if output file exists")?,
"Output file {b:?} was created"
);
match keep_going {
true => zutil_app_error::ensure!(
true => app_error::ensure!(
c1.try_exists().context("Unable to check if output file exists")?,
"Output file {c1:?} was missing"
),
false => zutil_app_error::ensure!(
false => app_error::ensure!(
!c1.try_exists().context("Unable to check if output file exists")?,
"Output file {c1:?} was created"
),
}
zutil_app_error::ensure!(
app_error::ensure!(
c2.try_exists().context("Unable to check if output file exists")?,
"Output file {c2:?} was missing"
);

View File

@ -11,7 +11,7 @@ use {
std::fs,
tempfile::TempDir,
zbuild::{AppError, Args},
zutil_app_error::Context,
app_error::Context,
};
/// Creates a directory with a zbuild manifest, then runs it, and returns the directory