package-missing
This, very simple but incredibly useful package contains a Constructor for the PackageMissingError
.
Usage
const PackageMissingError = // What would work if another package was installed?const task = 'Can not parse the file test.yml' // What packages can be installed to make this work?const recommendedPackages = 'js-yaml' 'yaml' const error = task recommendedPackages // You can test for this codeerrorcode === 'EPACKAGEMISSING' // ... or for the package-missing-errorerror instanceof PackageMissingError // The input is available to be processederrortask === taskerrorrecommendedPackages === recommendedPackages // The message recommends to install the mentioned packageserrormessage === errorcode + ': ' + errormessage + '\n' + 'This error can be easily fixed by running ONE of the following commands:\n' + recommendedPackages // The error comes with a stack, but if you don't like it ...typeof errorstack === 'string'
License
ISC