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

[GH-92] Simplify error handling for error call responses #93

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bdoodo
Copy link

@bdoodo bdoodo commented Jan 17, 2022

Summary

Simplified error handling logic by replacing their try/catch blocks with a helper function stored in utils.

Ticket Link

Fixes #92

@mattermod
Copy link

Hello @bdoodo,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@hanzei hanzei requested review from jfrerich and mickmister January 17, 2022 08:25
@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Jan 17, 2022
Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

Hi @bdoodo! Welcome to the Mattermost community 🎉

Thanks for this pull request! The code is nice and flat now 👍

I have one request to apply this strategy in a few other places. Looking through the code, a similar improvement can be added to these files:

  • fCreateTicket.ts
  • fDisconnect.ts
  • fSubscriptions.ts
  • fTarget.ts

Let me know what you think about this @bdoodo

+20 -52 Nice diff, I love seeing that!

@bdoodo
Copy link
Author

bdoodo commented Jan 19, 2022

Thanks for the encouragement, I'm on it! @mickmister

@mattermod
Copy link

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @aspleenic

@jfrerich jfrerich requested a review from mickmister February 10, 2022 18:18
Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

Thanks, @bdoodo! This is fantastic :)

Copy link
Contributor

@mickmister mickmister 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 adding the improvements @bdoodo! I have a request to avoid using then() in the spots we've refactored here. The main purpose of these improvements is to make the code more readable, and more specifically more "flat".

When we have indented code, it's difficult for a developer to parse the important parts when reading the code. If we treat each await'd statement as a discrete operation, with no important logic indented, then it's much easier to read.

I apologize for taking so long to get back to this. To make sure the reviewers are aware that they need to re-review the PR, please use GitHub's review request feature, by clicking the icon with arrows here:

image

src/utils/utils.ts Outdated Show resolved Hide resolved
src/restapi/fTarget.ts Outdated Show resolved Hide resolved
@bdoodo bdoodo requested a review from mickmister February 27, 2022 18:55
@bdoodo
Copy link
Author

bdoodo commented Feb 27, 2022

Sorry for the long delay; my courseload has been heavier than anticipated. Moving forward in future tasks, I'll make sure to communicate timing difficulties and only take on tasks I'm very confident I'll be able to commit to for their full review cycle.

Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

LGTM! Just one remaining suggestion to add a newline after each of the tryCallResponseWithMessage operations

Comment on lines +86 to +87
await tryCallResponseWithMessage(app.createBotDMPost(dmText), 'fOauth2Complete - Unable to create bot DM post', res);
const callResponse: AppCallResponse = newOKCallResponse();
Copy link
Contributor

Choose a reason for hiding this comment

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

I genuinely feel that you can ignore this request, as there has already been a decent amount back-and-forth on the PR, and I don't want to bog down you with more requests. Though here is the suggestion:

I suggest we add a newline after every tryCallResponseWithMessage operation, mainly to improve readability.

Suggested change
await tryCallResponseWithMessage(app.createBotDMPost(dmText), 'fOauth2Complete - Unable to create bot DM post', res);
const callResponse: AppCallResponse = newOKCallResponse();
await tryCallResponseWithMessage(app.createBotDMPost(dmText), 'fOauth2Complete - Unable to create bot DM post', res);
const callResponse: AppCallResponse = newOKCallResponse();

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Mick, I'm enjoying learning about codebase conventions. So since the emphasis would be on making important code readable, I should also add a space above if it looks cramped, and it's more of an art than a science, right? Feels like a silly question to ask, but when the scope is on spacing, I want to make sure I'm not making a mistake haha

Copy link
Contributor

Choose a reason for hiding this comment

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

So since the emphasis would be on making important code readable, I should also add a space above if it looks cramped

The convention is to "place newlines after blocks". If it is a block that is preceeding the call to tryCallResponseWithMessage then there should be a newline. In the case of this project, a block would be any multi-line statement, whether that be a function call with its arguments are expanded across multiple lines, or an actual block such as an if block or for loop block.

@hanzei hanzei requested a review from DHaussermann February 28, 2022 09:59
@hanzei hanzei removed 2: Dev Review Requires review by a core committer Lifecycle/1:stale labels Feb 28, 2022
@hanzei hanzei added this to the v0.2.2 milestone Feb 28, 2022
@mattermod
Copy link

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@hanzei hanzei added the Awaiting Submitter Action Blocked on the author label Feb 3, 2023
@hanzei hanzei modified the milestones: v0.3.0, v0.4.0 Feb 3, 2023
@hanzei hanzei removed the request for review from DHaussermann October 16, 2023 20:14
@hanzei
Copy link
Collaborator

hanzei commented Oct 16, 2023

@bdoodo Would you please merge merge master into your PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: QA Review Requires review by a QA tester Awaiting Submitter Action Blocked on the author Lifecycle/1:stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify error handling for error call responses
5 participants