-
Notifications
You must be signed in to change notification settings - Fork 28
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 #24 from snyk/fix/error-codes
fix: add code to all errors
- Loading branch information
Showing
13 changed files
with
194 additions
and
37 deletions.
There are no files selected for viewing
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,3 @@ | ||
export {InvalidUserInputError} from './invalid-user-input-error'; | ||
export {UnsupportedRuntimeError} from './unsupported-runtime-error'; | ||
export {OutOfSyncError} from './out-of-sync-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class InvalidUserInputError extends Error { | ||
public code = 422; | ||
public name = 'InvalidUserInputError'; | ||
|
||
constructor(...args) { | ||
super(...args); | ||
Error.captureStackTrace(this, InvalidUserInputError); | ||
} | ||
} |
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,26 @@ | ||
const LOCK_FILE_NAME = { | ||
npm: 'package-lock.json', | ||
yarn: 'yarn.lock', | ||
}; | ||
|
||
const INSTALL_COMMAND = { | ||
npm: 'npm install', | ||
yarn: 'yarn install', | ||
}; | ||
|
||
export class OutOfSyncError extends Error { | ||
public code = 422; | ||
public name = 'OutOfSyncError'; | ||
public dependencyName: string; | ||
public lockFileType: string; | ||
|
||
constructor(dependencyName: string, lockFileType: 'yarn' | 'npm') { | ||
super(`Dependency ${dependencyName} was not found in ` + | ||
`${LOCK_FILE_NAME[lockFileType]}. Your package.json and ` + | ||
`${LOCK_FILE_NAME[lockFileType]} are probably out of sync. Please run ` + | ||
`"${INSTALL_COMMAND[lockFileType]}" and try again.`); | ||
this.dependencyName = dependencyName; | ||
this.lockFileType = lockFileType; | ||
Error.captureStackTrace(this, OutOfSyncError); | ||
} | ||
} |
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,9 @@ | ||
export class UnsupportedRuntimeError extends Error { | ||
public name = 'UnsupportedRuntimeError'; | ||
public code = 500; | ||
|
||
constructor(...args) { | ||
super(...args); | ||
Error.captureStackTrace(this, UnsupportedRuntimeError); | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
{ | ||
"name": "trucolor", | ||
"version": "0.7.1", | ||
"description": "TTY color toolkit supporting Truecolor (24bit RGB)", | ||
"author": "Mark Griffiths <[email protected]> (http://thebespokepixel.com/)", | ||
"main": "index.js", | ||
"module": "index.mjs", | ||
"dependencies": { | ||
"debug": "2.0.x", | ||
"lodash": "4.17.11" | ||
}, | ||
"engines": { | ||
"node": ">=8.0" | ||
}, | ||
"homepage": "https://github.com/MarkGriffiths/trucolor", | ||
"license": "MIT" | ||
} |
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,15 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
[email protected]: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.0.0.tgz#89bd9df6732b51256bc6705342bba02ed12131ef" | ||
dependencies: | ||
ms "0.6.2" | ||
|
||
[email protected]: | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/ms/-/ms-0.6.2.tgz#d89c2124c6fdc1353d65a8b77bf1aac4b193708c" | ||
dependencies: | ||
debug "2.0.x" |
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