Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEN-105, H-3342: Move workspace to error-stack v0.6 #5200

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 22 additions & 35 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 @@ -70,7 +70,7 @@ type-system.path = "libs/@blockprotocol/type-system/rust"
validation.path = "libs/@local/hash-validation"

# Pinned workspace members
error-stack = { version = "=0.5.0", 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 @@ -17,6 +17,7 @@
"dependencies": {
"@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/hash-tracing": "0.0.0-private",
Expand Down
1 change: 1 addition & 0 deletions apps/hash-graph/libs/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"@blockprotocol/type-system-rs": "0.0.0-private",
"@rust/authorization": "0.0.0-private",
"@rust/error-stack": "0.5.0",
"@rust/graph": "0.0.0-private",
"@rust/graph-type-defs": "0.0.0-private",
"@rust/graph-types": "0.0.0-private",
Expand Down
8 changes: 6 additions & 2 deletions apps/hash-graph/libs/api/src/rest/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ where
actor_id,
// Manually deserialize the query from a JSON value to allow borrowed deserialization
// and better error reporting.
GetDataTypesParams::deserialize(&request).map_err(report_to_response)?,
GetDataTypesParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down Expand Up @@ -506,7 +508,9 @@ where
actor_id,
// Manually deserialize the query from a JSON value to allow borrowed deserialization
// and better error reporting.
GetDataTypeSubgraphParams::deserialize(&request).map_err(report_to_response)?,
GetDataTypeSubgraphParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down
24 changes: 18 additions & 6 deletions apps/hash-graph/libs/api/src/rest/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ where
S: StorePool + Send + Sync,
A: AuthorizationApiPool + Send + Sync,
{
let params = CreateEntityRequest::deserialize(&body).map_err(report_to_response)?;
let params = CreateEntityRequest::deserialize(&body)
.map_err(Report::from)
.map_err(report_to_response)?;

let authorization_api = authorization_api_pool
.acquire()
Expand Down Expand Up @@ -309,7 +311,9 @@ where
S: StorePool + Send + Sync,
A: AuthorizationApiPool + Send + Sync,
{
let params = Vec::<CreateEntityRequest>::deserialize(&body).map_err(report_to_response)?;
let params = Vec::<CreateEntityRequest>::deserialize(&body)
.map_err(Report::from)
.map_err(report_to_response)?;

let authorization_api = authorization_api_pool
.acquire()
Expand Down Expand Up @@ -359,7 +363,9 @@ where
S: StorePool + Send + Sync,
A: AuthorizationApiPool + Send + Sync,
{
let params = ValidateEntityParams::deserialize(&body).map_err(report_to_response)?;
let params = ValidateEntityParams::deserialize(&body)
.map_err(Report::from)
.map_err(report_to_response)?;

let authorization_api = authorization_api_pool
.acquire()
Expand Down Expand Up @@ -587,7 +593,9 @@ where
.await
.map_err(report_to_response)?;

let request = GetEntitiesRequest::deserialize(&request).map_err(report_to_response)?;
let request = GetEntitiesRequest::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?;
store
.get_entities(
actor_id,
Expand Down Expand Up @@ -723,7 +731,9 @@ where
.await
.map_err(report_to_response)?;

let request = GetEntitySubgraphRequest::deserialize(&request).map_err(report_to_response)?;
let request = GetEntitySubgraphRequest::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?;
store
.get_entity_subgraph(
actor_id,
Expand Down Expand Up @@ -809,7 +819,9 @@ where
store
.count_entities(
actor_id,
CountEntitiesParams::deserialize(&request).map_err(report_to_response)?,
CountEntitiesParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map(Json)
Expand Down
8 changes: 6 additions & 2 deletions apps/hash-graph/libs/api/src/rest/entity_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ where
actor_id,
// Manually deserialize the query from a JSON value to allow borrowed deserialization
// and better error reporting.
GetEntityTypesParams::deserialize(&request).map_err(report_to_response)?,
GetEntityTypesParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down Expand Up @@ -802,7 +804,9 @@ where
store
.get_entity_type_subgraph(
actor_id,
GetEntityTypeSubgraphParams::deserialize(&request).map_err(report_to_response)?,
GetEntityTypeSubgraphParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down
8 changes: 6 additions & 2 deletions apps/hash-graph/libs/api/src/rest/property_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ where
actor_id,
// Manually deserialize the query from a JSON value to allow borrowed deserialization
// and better error reporting.
GetPropertyTypesParams::deserialize(&request).map_err(report_to_response)?,
GetPropertyTypesParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down Expand Up @@ -496,7 +498,9 @@ where
store
.get_property_type_subgraph(
actor_id,
GetPropertyTypeSubgraphParams::deserialize(&request).map_err(report_to_response)?,
GetPropertyTypeSubgraphParams::deserialize(&request)
.map_err(Report::from)
.map_err(report_to_response)?,
)
.await
.map_err(report_to_response)
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-graph/libs/api/src/rest/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where
response
}

pub(crate) fn report_to_response<C>(report: impl Into<Report<C>>) -> Response
pub(crate) fn report_to_response<C>(report: impl Into<Report<[C]>>) -> Response
where
C: Context,
{
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-graph/libs/graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tokio-postgres = { workspace = true, public = true }

# Private workspace dependencies
codec = { workspace = true }
error-stack = { workspace = true, features = ["std", "serde"] }
error-stack = { workspace = true, features = ["std", "serde", "unstable"] }
graph-types = { workspace = true, features = ["postgres"] }
hash-status = { workspace = true }
temporal-versioning = { workspace = true, features = ["postgres"] }
Expand Down
1 change: 1 addition & 0 deletions apps/hash-graph/libs/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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-types": "0.0.0-private",
"@rust/hash-graph-store": "0.0.0-private",
"@rust/hash-status": "0.0.0-private",
Expand Down
Loading
Loading