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

[Reporting] Refactor error messages with human-friendly version of message #136501

Merged
merged 3 commits into from
Jul 22, 2022

Conversation

jloleysens
Copy link
Contributor

Summary

Adds a new method to ReportingError to retrieve the human-friendly version of an error message. Currently the code for doing this is a bit convoluted and this refactor attempts to make this functionality more explicit and simpler.

@jloleysens jloleysens added chore (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes Team:Reporting Services auto-backport Deprecated - use backport:version if exact versions are needed v8.4.0 labels Jul 18, 2022
@jloleysens jloleysens requested review from tsullivan and dokmic July 18, 2022 08:49
@jloleysens jloleysens requested review from a team as code owners July 18, 2022 08:49
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@jloleysens jloleysens requested a review from gchaps July 19, 2022 08:15
Copy link
Contributor

@kellyemurphy kellyemurphy left a comment

Choose a reason for hiding this comment

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

Some small text changes and a couple questions.

When we write error messages, it's helpful to let the users know what to do to solve the issue.

x-pack/plugins/reporting/common/errors/index.ts Outdated Show resolved Hide resolved
x-pack/plugins/reporting/common/errors/index.ts Outdated Show resolved Hide resolved
x-pack/plugins/reporting/common/errors/index.ts Outdated Show resolved Hide resolved
/**
* Return a message describing the error that is human friendly
*/
humanFriendlyMessage?(): string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am just curious why you decided not to go with the built-in toString() method? That seems like it can very well fit into our use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question!

In most cases on the server-side we will be using the default toString behaviour. But when storing this as a message on the Reporting document (where it is seen by users) sometimes we want to have a special human-friendlier version of the stringified error. Does that make sense? Is there another way to achieve this? Perhaps toString('humanFriendly')?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, @jloleysens. That makes total sense now 👍

No need to overcomplicate this. The current solution is clear enough.

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@dokmic dokmic left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
reporting 42.5KB 42.4KB -144.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jloleysens jloleysens merged commit af3a3cb into elastic:main Jul 22, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 22, 2022
@jloleysens jloleysens deleted the refactor-reporting-errors branch July 22, 2022 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed backport:skip This commit does not require backporting chore (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants