-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from snyk/fix/cli-error-message-on-snyk-test
fix: cli error message when <snyk test> command fails.
- Loading branch information
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/lib/errors/failed-to-get-vulns-from-unavailable-resource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CustomError } from './custom-error'; | ||
|
||
const errorNpmMessage = | ||
'Please check the version and package name and try running `snyk test` again.\nFor additional assistance, run `snyk help` or check out our docs \n(link to: https://support.snyk.io/hc/en-us/articles/360003851277#UUID-ba99a73f-110d-1f1d-9e7a-1bad66bf0996).'; | ||
const errorRepositoryMessage = | ||
'Try testing this repository at https://snyk.io/test/.\nFor additional assistance, run `snyk help` or check out our docs \n(link to: https://support.snyk.io/hc/en-us/articles/360003851277#UUID-ba99a73f-110d-1f1d-9e7a-1bad66bf0996).'; | ||
|
||
export function FailedToGetVulnsFromUnavailableResource( | ||
root: string, | ||
statusCode: number, | ||
): CustomError { | ||
const isRepository = root.startsWith('http' || 'https'); | ||
const errorMsg = `We couldn't test ${root}. ${ | ||
isRepository ? errorRepositoryMessage : errorNpmMessage | ||
}`; | ||
const error = new CustomError(errorMsg); | ||
error.code = statusCode; | ||
error.userMessage = errorMsg; | ||
return error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters