app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 887a1c6991744be3fc9ab28d275e051f6d109795
parent fe6ceaa298a4b22801a349355e33689bf0d0fca2
Author: triesap <triesap@radroots.dev>
Date:   Mon, 19 Jan 2026 06:42:01 +0000

app-utils: add err_msg helper

- add err_msg formatting helper
- add error prefix constants
- export err_msg helper
- add unit tests for err_msg

Diffstat:
MCargo.lock | 7+++++++
MCargo.toml | 1+
Mcrates/utils/Cargo.toml | 1+
Acrates/utils/src/errors.rs | 27+++++++++++++++++++++++++++
Mcrates/utils/src/lib.rs | 2++
5 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1562,6 +1562,13 @@ dependencies = [ ] [[package]] +name = "radroots-app-utils" +version = "0.1.0" +dependencies = [ + "radroots-types", +] + +[[package]] name = "radroots-core" version = "0.1.0" dependencies = [ diff --git a/Cargo.toml b/Cargo.toml @@ -69,6 +69,7 @@ chrono = "0.4" hex = "0.4" sha2 = "0.10" radroots-nostr = { path = "refs/crates/nostr" } +radroots-types = { path = "refs/crates/types" } radroots-sql-core = { path = "refs/crates/sql-core" } radroots-tangle-db = { path = "refs/crates/tangle-db" } radroots-tangle-db-schema = { path = "refs/crates/tangle-db-schema" } diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml @@ -10,3 +10,4 @@ rust-version.workspace = true crate-type = ["rlib"] [dependencies] +radroots-types = { workspace = true } diff --git a/crates/utils/src/errors.rs b/crates/utils/src/errors.rs @@ -0,0 +1,27 @@ +#![forbid(unsafe_code)] + +use radroots_types::types::IError; + +pub const ERR_PREFIX_APP: &str = "error.app"; +pub const ERR_PREFIX_UTILS: &str = "error.app.utils"; + +pub fn err_msg(err: impl Into<String>) -> IError<String> { + IError { err: err.into() } +} + +#[cfg(test)] +mod tests { + use super::{err_msg, ERR_PREFIX_APP, ERR_PREFIX_UTILS}; + + #[test] + fn err_msg_wraps_string() { + let err = err_msg("boom"); + assert_eq!(err.err, "boom"); + } + + #[test] + fn error_prefixes_match_spec() { + assert_eq!(ERR_PREFIX_APP, "error.app"); + assert_eq!(ERR_PREFIX_UTILS, "error.app.utils"); + } +} diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs @@ -1,6 +1,8 @@ #![forbid(unsafe_code)] pub mod error; +pub mod errors; pub mod types; +pub use errors::{err_msg, ERR_PREFIX_APP, ERR_PREFIX_UTILS}; pub use types::{resolve_err, resolve_ok, ResolveError, ResultPass};