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

Refactored flow error checks #1953

Merged
merged 6 commits into from Mar 13, 2019
Merged
Diff settings

Always

Just for now

fix types

  • Loading branch information...
juliangruber committed Mar 12, 2019
commit bd076506dc056ec192d02636567f72e5eeab14d7
Copy path View file
@@ -215,6 +215,8 @@ export default async function set(
);
if (handleResult === 1) {
return 1;
} else if (handleResult instanceof Error) {
throw handleResult;
This conversation was marked as resolved by juliangruber

This comment has been minimized.

Copy link
@javivelasco

javivelasco Mar 13, 2019

Member

Why throw? Who's handling this?

} else {
console.log(
`${chalk.cyan('> Success!')} ${
@@ -367,7 +369,7 @@ type RemainingAssignAliasErrors = SetDifference<
function handleCreateAliasError<T>(
output: Output,
error: RemainingAssignAliasErrors | T
): 1 | T {
): 1 | Error | T {
This conversation was marked as resolved by juliangruber

This comment has been minimized.

Copy link
@javivelasco

javivelasco Mar 13, 2019

Member

This is incorrect IIRC. This function is deliberately implemented to return 1 (when the error is handled) or something else, but not an error. When it returns an error instance it means that there was a known error received that wasn't handled so if you check at the end of the pattern match you'll see the remaining values that should be handled.

if (error instanceof ERRORS.AliasInUse) {
output.error(
`The alias ${chalk.dim(
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.