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

Add logic to catch clause #1183

Merged
merged 2 commits into from Jan 15, 2019
Merged

Add logic to catch clause #1183

merged 2 commits into from Jan 15, 2019

Conversation

DanielRuf
Copy link
Contributor

Type:
bug

The following has been addressed in the PR:

  • There is a related issue?
  • Unit or Functional tests are included in the PR

Description:

A catch clause that only rethrows the caught exception has the same effect as omitting the catch altogether and letting it bubble up automatically, but with more code and the additional detriment of leaving maintainers scratching their heads.

Such clauses should either be eliminated or populated with the appropriate logic.

@@ -45,6 +45,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth)
permissions.push(pkg);
}
} catch (err) {
console.error(err)
Copy link
Member

Choose a reason for hiding this comment

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

Problem is the eslint don't allow console.error on code. Here we should use the logger object.

/home/circleci/verdaccio/src/api/web/endpoint/package.js
  48:13  error  Unexpected console statement  no-console
  48:31  error  Missing semicolon             semi

Instead I would

import logger from '../../../lib/logger';

// below 
logger.logger.error({name: pkg.name, error }, 'permission process for @{name} has failed: @{error}');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will change it in about 1 - 2 hours.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we run the eslint checks or how can I make sure to catch such things like you mention?

Copy link
Member

Choose a reason for hiding this comment

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

If you remove the console.error(err) all should be fine. But you can run locally yarn lint to check all lint pass. https://github.com/verdaccio/verdaccio/wiki/Build-Source-Code#scripts-1

Copy link
Contributor Author

@DanielRuf DanielRuf Jan 14, 2019

Choose a reason for hiding this comment

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

Ah, CI is red because of this which is good =). I guess I either oversaw it or it took some time after my changes.

@juanpicado juanpicado merged commit 056d396 into verdaccio:master Jan 15, 2019
@DanielRuf DanielRuf deleted the fix/add-catch-logic branch March 17, 2019 19:21
@lock
Copy link

lock bot commented Jun 15, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants