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

refactor(error): clean-up direct error formatting (part 2) #13870

Merged
merged 4 commits into from
Dec 11, 2023

Conversation

yuhao-su
Copy link
Contributor

@yuhao-su yuhao-su commented Dec 8, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

follow up #13763

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@yuhao-su yuhao-su requested a review from BugenZhao December 8, 2023 06:29
@yuhao-su yuhao-su marked this pull request as ready for review December 8, 2023 08:03
@yuhao-su yuhao-su requested a review from a team as a code owner December 8, 2023 08:03
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (d425053) 68.29% compared to head (78f2fcf) 68.26%.
Report is 34 commits behind head on main.

Files Patch % Lines
src/jni_core/src/jvm_runtime.rs 0.00% 15 Missing ⚠️
src/frontend/src/scheduler/distributed/stage.rs 0.00% 10 Missing ⚠️
src/frontend/src/binder/relation/mod.rs 0.00% 5 Missing ⚠️
src/jni_core/src/lib.rs 0.00% 5 Missing ⚠️
src/frontend/src/scheduler/distributed/query.rs 42.85% 4 Missing ⚠️
src/frontend/planner_test/src/lib.rs 25.00% 3 Missing ⚠️
...rc/frontend/src/binder/relation/table_or_source.rs 0.00% 3 Missing ⚠️
src/expr/impl/src/scalar/jsonb_path.rs 0.00% 2 Missing ⚠️
...c/frontend/src/expr/function_impl/cast_regclass.rs 0.00% 2 Missing ⚠️
src/frontend/src/handler/explain.rs 0.00% 2 Missing ⚠️
... and 15 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13870      +/-   ##
==========================================
- Coverage   68.29%   68.26%   -0.03%     
==========================================
  Files        1525     1525              
  Lines      262324   262329       +5     
==========================================
- Hits       179143   179088      -55     
- Misses      83181    83241      +60     
Flag Coverage Δ
rust 68.26% <20.93%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM. Good work!

@@ -32,6 +32,9 @@
#![feature(iterator_try_collect)]
#![feature(try_blocks)]
#![feature(error_generic_member_access)]
#![feature(register_tool)]
#![register_tool(rw)]
#![allow(rw::format_error)] // TODO: remove this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#![allow(rw::format_error)] // TODO: remove this
#![allow(rw::format_error)] // TODO(error-handling): need further refactoring

@@ -300,7 +301,7 @@ pub async fn resize(ctl_ctx: &CtlContext, scale_ctx: ScaleCommandContext) -> any
} = match response {
Ok(response) => response,
Err(e) => {
fail!("Failed to generate plan: {:?}", e);
fail!("Failed to generate plan: {:?}", e.as_report());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Display (without backtrace) is enough. Backtraces on the client side does not make sense.

Suggested change
fail!("Failed to generate plan: {:?}", e.as_report());
fail!("Failed to generate plan: {}", e.as_report());

@@ -364,7 +365,7 @@ pub async fn resize(ctl_ctx: &CtlContext, scale_ctx: ScaleCommandContext) -> any
match meta_client.reschedule(reschedules, revision, false).await {
Ok(response) => response,
Err(e) => {
fail!("Failed to execute plan: {:?}", e);
fail!("Failed to execute plan: {:?}", e.as_report());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -391,7 +392,7 @@ pub async fn update_schedulability(
let GetClusterInfoResponse { worker_nodes, .. } = match meta_client.get_cluster_info().await {
Ok(resp) => resp,
Err(e) => {
fail!("Failed to get cluster info: {:?}", e);
fail!("Failed to get cluster info: {:?}", e.as_report());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -63,9 +63,11 @@ pub enum ExprError {
DivisionByZero,

#[error("Parse error: {0}")]
// TODO: error-handling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO(error-handling): should prefer use error types than strings.

@@ -156,7 +157,9 @@ impl StreamFragmentGraph {
.map_err(|e| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map_err(|e| {
.with_context(|| format!("edge .. exists"))?;

Comment on lines 53 to 54
.map_err(|e| format!("unable to get path of current_exe: {:?}", e))?
.map_err(|e| format!("unable to get path of current_exe: {:?}", e.as_report()))?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest returning anyhow::Result for this function and using context.

Comment on lines 117 to 118
.map_err(|e| format!("invalid jvm args: {:?}", e))?;
.map_err(|e| format!("invalid jvm args: {:?}", e.as_report()))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -128,7 +129,7 @@ impl JavaVmWrapper {
tracing::info!("initialize JVM successfully");

register_native_method_for_jvm(&jvm)
.map_err(|e| format!("failed to register native method: {:?}", e))?;
.map_err(|e| format!("failed to register native method: {:?}", e.as_report()))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -39,6 +39,7 @@ pub enum ErrorInner {
Arrow(#[from] arrow_schema::ArrowError),

#[error("UDF unsupported: {0}")]
// TODO: error-handling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: error-handling
// TODO(error-handling): should prefer use error types than strings.

@yuhao-su yuhao-su requested a review from BugenZhao December 11, 2023 07:11
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants