ExtendedError
makes it easier to create Error
with custom properties
Install from the command line:
$ npm install @tfso/extended-error@1.0.0 --save
Install via package.json:
"@tfso/extended-error": "1.0.0"
const ExtendedError = require('@tfso/extended-error') // as a JavaScript package
// or
const { ExtendedError } = require('@tfso/extended-error') // access the class itself
import ExtendedError from '@tfso/extended-error' // as a TypeScript package
// or
import { ExtendedError } from '@tfso/extended-error' // access the class itself
import { ExtendedError } from '@tfso/extended-error'
const error = new ExtendedError('Not found', { status: 404 })
console.log(error.message) // Not found
console.log(error.status) // 404
console.log(error instanceof Error) // true
console.log(error instanceof ExtendedError) // true
console.log(error.stack) // 'Error: Not found\n at repl:1:9\n ...
This:
throw new ExtendedError('Not found', { status: 404 })
is equivalent to:
const error = new Error('Not found')
error.status = 404
throw error
https://gist.github.com/slavafomin/b164e3e710a6fc9352c934b9073e7216
The CHANGELOG.md is automatically generated by auto-changelog
by analysing PR, tags and commits.
You are welcome to contribute to the project by creating a pull request. Please follow the guidelines below to contribute effectively.
To create a pull request, follow these steps:
- Create a new branch for your feature or bug fix.
git checkout -b feature/your-feature
- Make your changes and ensure they follow our coding standards.
- Include
#deploy_branch
in your commit message in order to create a prerelease of your branch
git add .
git commit -m "Descriptive commit message #deploy_branch"
- Push your changes to the repository.
git push origin feature/your-feature
- Go this repository on GitHub
- Click on "New Pull Request."
- Provide a detailed description of your changes.
- Add a reviewer to your pull request.
If you need to test your branch during development, create a commit that includes #deploy_branch
in the commit message.
This will trigger a prerelease, allowing you to test in your project without creating a full package release.
- auto prerelease on commit message
#deploy_branch
- auto prerelease from
main
branch
To create a new official release that update the latest
release of the package, follow these steps:
- Ensure your changes are merged into the main branch.
- Go to the GitHub repository.
- Click on the "Releases" tab.
- Click "Draft a new release."
- Choose a version number following semantic versioning (e.g., v1.0.0).
- Provide release notes summarizing the changes since the last release.
- Click "Publish release" to make it official.
Thank you for your contribution!