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

#9 More verbose error messages: include package name #13

Merged
merged 2 commits into from
Oct 13, 2019

Conversation

emimuresan
Copy link
Contributor

Description

Provide more verbose information - which includes the package name - on errors encountered during validation. In order to solve this I created a custom error type called PackageError which prints out the package name as well as the original error message and stacktrace. It is used in validators.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Related Issue

#9

Motivation and Context

More informative error message.

How Has This Been Tested?

Added a test-case for each validator. Based on mocked packages containing a bad url these test cases assert that PackageError was thrown.

Screenshots (if appropriate):

Example output:

$ lockfile-lint -p bad-yarn.lock --allowed-hosts yarn --validate-https -t yarn
ABORTING lockfile lint process due to error exceptions 

Encountered error Invalid URL: /registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791 in package: "debug@^4.1.1" 

TypeError [ERR_INVALID_URL]: Invalid URL: /registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791
    at onParseError (internal/url.js:241:17)
    at new URL (internal/url.js:319:5)
    at ValidateHost.validate ...

error: command failed with exit code 1

Checklist:

  • I have updated the documentation (if required).
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I added a picture of a cute animal cause it's fun

cat

@codecov-io
Copy link

codecov-io commented Oct 12, 2019

Codecov Report

Merging #13 into master will increase coverage by 0.48%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #13      +/-   ##
=========================================
+ Coverage   95.62%   96.1%   +0.48%     
=========================================
  Files           8       9       +1     
  Lines         137     154      +17     
  Branches       20      21       +1     
=========================================
+ Hits          131     148      +17     
  Misses          6       6
Impacted Files Coverage Δ
...kages/lockfile-lint-api/src/common/PackageError.js 100% <100%> (ø)
.../lockfile-lint-api/src/validators/ValidateHttps.js 100% <100%> (ø) ⬆️
...lockfile-lint-api/src/validators/ValidateScheme.js 94.73% <100%> (+1.4%) ⬆️
...s/lockfile-lint-api/src/validators/ValidateHost.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a5b3c...ffd5291. Read the comment docs.

@lirantal
Copy link
Owner

Great job @emimuresan, looks fantastic! ✨
I will merge this in and also open a couple more issues that reviewing this brought up and you're welcome to give them a stab as well if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants