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

remove panic & wrapping informational error #501

Closed
wants to merge 8 commits into from
Closed

Conversation

emplam27
Copy link
Contributor

@emplam27 emplam27 commented Mar 24, 2023

What this PR does / why we need it:

ref. https://github.com/uber-go/guide/blob/master/style.md#dont-panic

Remove panic() in server production

  • Change function from using panic to return error and caller to decide how to handle it.
  • Wrapping error more informationally

Remove panic method & Wrapping errors in CRDT logics

  • Currently, if error occurred in CRDT logic, server was shutdown because of panic() method
  • Removed panic() methods & Change all errors able to logging

Which issue(s) this PR fixes:

Fixes #497

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Merging #501 (49e70c8) into main (969e509) will decrease coverage by 1.63%.
The diff coverage is 29.37%.

@@            Coverage Diff             @@
##             main     #501      +/-   ##
==========================================
- Coverage   50.61%   48.98%   -1.63%     
==========================================
  Files          64       64              
  Lines        5751     5985     +234     
==========================================
+ Hits         2911     2932      +21     
- Misses       2471     2615     +144     
- Partials      369      438      +69     
Impacted Files Coverage Δ
api/converter/to_bytes.go 83.33% <0.00%> (ø)
api/converter/to_pb.go 63.87% <0.00%> (ø)
api/types/client.go 0.00% <0.00%> (ø)
client/client.go 15.38% <ø> (ø)
internal/validation/validation.go 45.52% <0.00%> (+0.72%) ⬆️
pkg/document/change/change.go 0.00% <0.00%> (ø)
pkg/document/crdt/object.go 20.51% <12.50%> (-3.02%) ⬇️
pkg/document/internal_document.go 21.87% <14.28%> (-0.16%) ⬇️
api/converter/from_pb.go 51.93% <14.45%> (-1.72%) ⬇️
pkg/document/crdt/array.go 24.63% <16.21%> (-11.73%) ⬇️
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@emplam27 emplam27 self-assigned this Mar 24, 2023
@hackerwins hackerwins marked this pull request as ready for review March 27, 2023 01:35
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

I think the interface has changed only for the function below:

  • validation.RegisterValidation
  • validation.RegisterTranslation
  • config.configPath
  • time.ParseDuration

Next, it would be nice to remove the panic that can occur in CRDT data structure.

- Currently, if error occurred in CRDT logic, server was shutdown because of `panic()` method
- Removed `panic()` methods & Change all errors able to logging
@hackerwins hackerwins self-requested a review April 13, 2023 03:32
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for the second work. I leave a few comments.

We need to check whether an actual error can occur

While removing panic, some interfaces have been changed to return an error. The changes may reduce the usability of interfaces, It is necessary to check whether an actual error can occur.

For example, there is a situation like below:

An error chain Text.String > RGATreeSplitNode.String > TextValue.String need not return an actual error.

func (t *TextValue) String() (string, error) {
	return t.value, nil
}

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

Successfully merging this pull request may close these issues.

Don't Panic in the Server
2 participants