Skip to content

Conversation

@simon-engledew
Copy link

Hide these warnings:

image

This will still send a LintFailed message status report.

@robertbrignull
Copy link
Contributor

This will still send a LintFailed message status report.

I don't think this will send a LintFailed message status report. If getWorkflow returns undefined then it does nothing. You want to change getWorkflowErrors to do

if (workflow === undefined) {
  return [WorkflowErrors.LintFailed];
}

Ideally we'd also have different kinds of LintFailed so we can tell between errors in the workflow and failing to read the workflow.

@robertbrignull
Copy link
Contributor

I agree this will silence the error message. Up to you if you want to also upload the failure message in the status report or just leave it.

@robertbrignull robertbrignull self-assigned this Jan 21, 2021
@simon-engledew simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch 3 times, most recently from 6b04c71 to 483255c Compare January 22, 2021 09:22
@simon-engledew
Copy link
Author

I don't think this will send a LintFailed message status report. If getWorkflow returns undefined then it does nothing.

Ugh, sorry - quite right. I should have actually checked this. 🤦 🙇

I've had a bit of a refactor and tweaked the way we report errors to include the exception string if something failed during linting

Copy link
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

One suggestion about a try-catch but LGTM regardless

}
} catch (e) {
return [WorkflowErrors.LintFailed];
return `error: getWorkflow() failed: ${e.toString()}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid this try-catch covering more than necessary you could do

let workflow: Workflow;
try {
  workflow = await getWorkflow();
} catch (e) {
  return `error: getWorkflow() failed: ${e.toString()}`;
}

and that way you can assign a variable to a non-nullable type but have the try-catch be more contained so it's easier to read and you won't unexpectedly catch something you didn't mean to.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, it's nice that the type checker is sophisticated enough to realise that the variable is not nullable!

I've used that technique to add more fine grained handling over the whole function, thanks! 👍

@simon-engledew simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from d947456 to fed7a74 Compare January 22, 2021 10:59
@simon-engledew simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from b3f3e39 to 6be1f5c Compare January 22, 2021 13:52
@simon-engledew simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from 3c9fbc6 to ee4d067 Compare January 22, 2021 14:08
@simon-engledew simon-engledew merged commit 7a340d3 into main Jan 25, 2021
@simon-engledew simon-engledew deleted the simon-engledew/hide-workflow-not-found branch January 25, 2021 09:21
@github-actions github-actions bot mentioned this pull request Jan 25, 2021
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.

3 participants