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

RSCBC-19: Rework analyticsx error model #242

Merged
merged 1 commit into from
Feb 3, 2025
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
21 changes: 5 additions & 16 deletions sdk/couchbase-core/src/analyticsx/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ impl<C: Client> Analytics<C> {
let on_behalf_of = opts.on_behalf_of;

let mut body = serde_json::to_value(opts).map_err(|e| {
Error::new_generic_error(
e.to_string(),
&self.endpoint,
statement,
client_context_id.clone(),
)
Error::new_encoding_error(format!("failed to encode query options: {}", e))
})?;

// Unwrap is fine, we know this is an object.
Expand All @@ -104,12 +99,7 @@ impl<C: Client> Analytics<C> {
}

let body = serde_json::to_vec(body_obj).map_err(|e| {
Error::new_generic_error(
e.to_string(),
&self.endpoint,
statement,
client_context_id.clone(),
)
Error::new_encoding_error(format!("failed to encode query options: {}", e))
})?;

let priority = opts.priority.map(|p| p.to_string());
Expand All @@ -133,13 +123,12 @@ impl<C: Client> Analytics<C> {
)
.await
.map_err(|e| {
Error::new_generic_error_with_source(
e.to_string(),
Error::new_http_error(
&self.endpoint,
statement,
statement.to_string(),
client_context_id.clone(),
Arc::new(e),
)
.with(Arc::new(e))
})?;

QueryRespReader::new(res, &self.endpoint, statement, client_context_id.clone()).await
Expand Down
Loading