Skip to content

Commit

Permalink
H-3548: Use in-tree version of error-stack again (#5563)
Browse files Browse the repository at this point in the history
Co-authored-by: Bilal Mahmoud <bmahmoud@mpi-cbg.de>
  • Loading branch information
TimDiekmann and indietyp authored Nov 4, 2024
1 parent 9609cd8 commit f67bc88
Show file tree
Hide file tree
Showing 154 changed files with 1,228 additions and 1,010 deletions.
67 changes: 27 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type-system.path = "libs/@blockprotocol/type-system/rust"
validation.path = "libs/@local/hash-validation"

# Pinned workspace members
error-stack = { git = "https://github.com/hashintel/hash", rev = "f6ecda1ec75f4aca1f738b2fbe413613a356069c", default-features = false }
error-stack = { path = "./libs/error-stack", default-features = false }

# Public dependencies
ahash = { version = "=0.8.11", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions apps/hash-graph/bins/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@blockprotocol/type-system-rs": "0.0.0-private",
"@rust/authorization": "0.0.0-private",
"@rust/codec": "0.0.0-private",
"@rust/error-stack": "0.5.0",
"@rust/graph": "0.0.0-private",
"@rust/graph-api": "0.0.0-private",
"@rust/graph-types": "0.0.0-private",
Expand Down
8 changes: 3 additions & 5 deletions apps/hash-graph/bins/cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use core::fmt;

use error_stack::Context;
use core::{error::Error, fmt};

#[derive(Debug)]
pub struct GraphError;
impl Context for GraphError {}
impl Error for GraphError {}

impl fmt::Display for GraphError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -27,4 +25,4 @@ impl fmt::Display for HealthcheckError {
}
}

impl Context for HealthcheckError {}
impl Error for HealthcheckError {}
4 changes: 2 additions & 2 deletions apps/hash-graph/bins/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod args;
mod error;
mod subcommand;

use error_stack::Result;
use error_stack::Report;
use graph::load_env;
use hash_tracing::sentry::{init, release_name};

Expand All @@ -21,7 +21,7 @@ use self::{args::Args, error::GraphError};
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

fn main() -> Result<(), GraphError> {
fn main() -> Result<(), Report<GraphError>> {
load_env(None);
graph_types::knowledge::property::error::install_error_stack_hooks();

Expand Down
4 changes: 2 additions & 2 deletions apps/hash-graph/bins/cli/src/subcommand/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use authorization::NoAuthorization;
use clap::Parser;
use error_stack::{Result, ResultExt as _};
use error_stack::{Report, ResultExt as _};
use graph::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool, StoreMigration as _,
StorePool as _,
Expand All @@ -19,7 +19,7 @@ pub struct MigrateArgs {
pub pool_config: DatabasePoolConfig,
}

pub async fn migrate(args: MigrateArgs) -> Result<(), GraphError> {
pub async fn migrate(args: MigrateArgs) -> Result<(), Report<GraphError>> {
let pool = PostgresStorePool::new(&args.db_info, &args.pool_config, NoTls)
.await
.change_context(GraphError)
Expand Down
12 changes: 6 additions & 6 deletions apps/hash-graph/bins/cli/src/subcommand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod type_fetcher;

use core::time::Duration;

use error_stack::{Result, ensure};
use error_stack::{Report, ensure};
use hash_tracing::{TracingConfig, init_tracing};
use tokio::{runtime::Handle, time::sleep};

Expand Down Expand Up @@ -51,9 +51,9 @@ pub enum Subcommand {
}

fn block_on(
future: impl Future<Output = Result<(), GraphError>>,
future: impl Future<Output = Result<(), Report<GraphError>>>,
tracing_config: TracingConfig,
) -> Result<(), GraphError> {
) -> Result<(), Report<GraphError>> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
Expand All @@ -68,7 +68,7 @@ fn block_on(
}

impl Subcommand {
pub(crate) fn execute(self, tracing_config: TracingConfig) -> Result<(), GraphError> {
pub(crate) fn execute(self, tracing_config: TracingConfig) -> Result<(), Report<GraphError>> {
match self {
Self::Server(args) => block_on(server(args), tracing_config),
Self::Migrate(args) => block_on(migrate(args), tracing_config),
Expand All @@ -89,10 +89,10 @@ pub async fn wait_healthcheck<F, Ret>(
func: F,
wait: bool,
wait_timeout: Option<Duration>,
) -> Result<(), HealthcheckError>
) -> Result<(), Report<HealthcheckError>>
where
F: Fn() -> Ret + Send,
Ret: Future<Output = Result<(), HealthcheckError>> + Send,
Ret: Future<Output = Result<(), Report<HealthcheckError>>> + Send,
{
let expected_end_time = wait_timeout.map(|timeout| std::time::Instant::now() + timeout);

Expand Down
4 changes: 2 additions & 2 deletions apps/hash-graph/bins/cli/src/subcommand/reindex_cache.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use authorization::NoAuthorization;
use clap::Parser;
use error_stack::{Report, Result, ResultExt as _, ensure};
use error_stack::{Report, ResultExt as _, ensure};
use graph::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool, StorePool as _,
knowledge::EntityStore as _, ontology::EntityTypeStore as _,
Expand Down Expand Up @@ -37,7 +37,7 @@ pub struct ReindexOperations {
pub entities: bool,
}

pub async fn reindex_cache(args: ReindexCacheArgs) -> Result<(), GraphError> {
pub async fn reindex_cache(args: ReindexCacheArgs) -> Result<(), Report<GraphError>> {
let pool = PostgresStorePool::new(&args.db_info, &args.pool_config, NoTls)
.await
.change_context(GraphError)
Expand Down
Loading

0 comments on commit f67bc88

Please sign in to comment.