Skip to content

Commit

Permalink
fix: improvement of errors messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthogez committed Feb 27, 2020
1 parent 1c78bd1 commit dffba72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { CustomError } from './custom-error';
import chalk from 'chalk';

const errorNpmMessage =
'\nplease check that the version and name are correct. See more details on what is supported `snyk help`';
'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 =
`\nplease try it on ${chalk.underline('`https://snyk.io/test/`')}` +
'. See more details on what is supported `snyk help`';
'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 = `Could not test ${root}, ${
const errorMsg = `We couldn't test ${root}. ${
isRepository ? errorRepositoryMessage : errorNpmMessage
}`;
const error = new CustomError(errorMsg);
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/cli-test/cli-test.generic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const GenericTests: AcceptanceTests = {
} catch (err) {
t.equal(
err.userMessage,
'Could not test npm-package, \nplease check that the version and name are correct. See more details on what is supported `snyk help`',
"We couldn't test npm-package. 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).",
'got correct err message',
);
}
Expand All @@ -58,7 +58,7 @@ export const GenericTests: AcceptanceTests = {
} catch (err) {
t.equal(
err.userMessage,
'Could not test ruby-app, \nplease check that the version and name are correct. See more details on what is supported `snyk help`',
"We couldn't test ruby-app. 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).",
'got correct err message',
);
}
Expand Down

0 comments on commit dffba72

Please sign in to comment.