Skip to content

Commit

Permalink
feat: special error for too many vuln paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dkontorovskyy committed Aug 5, 2019
1 parent 842ef7f commit 82e7ca6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export {FailedToGetVulnerabilitiesError} from './failed-to-get-vulnerabilities-e
export {UnsupportedFeatureFlagError} from './unsupported-feature-flag-error';
export {UnsupportedPackageManagerError} from './unsupported-package-manager-error';
export {FailedToRunTestError} from './failed-to-run-test-error';
export {TooManyVulnPaths} from './too-many-vuln-paths';
14 changes: 14 additions & 0 deletions src/lib/errors/too-many-vuln-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {CustomError} from './custom-error';

export class TooManyVulnPaths extends CustomError {
private static ERROR_CODE: number = 413;
private static ERROR_STRING_CODE: string = 'TOO_MANY_VULN_PATHS';
private static ERROR_MESSAGE: string = 'Too many vulnerable paths to process the project';

constructor() {
super(TooManyVulnPaths.ERROR_MESSAGE);
this.code = TooManyVulnPaths.ERROR_CODE;
this.strCode = TooManyVulnPaths.ERROR_STRING_CODE;
this.userMessage = TooManyVulnPaths.ERROR_MESSAGE;
}
}
3 changes: 2 additions & 1 deletion src/lib/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DepGraph, legacy } from '@snyk/dep-graph';

import { DepTree } from './types';
import * as config from './config';
import { TooManyVulnPaths } from './errors';
import { SupportedPackageManagers } from './package-managers';

const debug = _debug('snyk:prune');
Expand Down Expand Up @@ -35,7 +36,7 @@ export async function pruneGraph(
}

debug('Too many vulnerable paths to process the project');
throw new Error('Too many vulnerable paths to process the project');
throw new TooManyVulnPaths();
} catch (e) {
debug('Failed to prune the graph, returning original: ' + e);
return depGraph;
Expand Down

0 comments on commit 82e7ca6

Please sign in to comment.