https://github.com/semantic-release/error
:boom: :speech_balloon: errors but with error code
https://github.com/semantic-release/error
error semantic-release
Last synced: 8 months ago
JSON representation
:boom: :speech_balloon: errors but with error code
- Host: GitHub
- URL: https://github.com/semantic-release/error
- Owner: semantic-release
- License: mit
- Created: 2015-07-13T16:02:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-28T03:55:30.000Z (9 months ago)
- Last Synced: 2025-04-28T04:31:17.563Z (9 months ago)
- Topics: error, semantic-release
- Language: JavaScript
- Homepage:
- Size: 1.18 MB
- Stars: 10
- Watchers: 3
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @semantic-release/error
Error type used by all [semantic-release](https://github.com/semantic-release/semantic-release) packages.
[](https://github.com/semantic-release/error/actions?query=workflow%3ATest+branch%3Amaster)
Errors of type `SemanticReleaseError` or an inherited type will be considered by [semantic-release](https://github.com/semantic-release/semantic-release) as an expected exception case (no release to be done, running on a PR etc..). That indicate to the `semantic-release` process to stop and exit with the `0` success code.
Any other type of error will be considered by [semantic-release](https://github.com/semantic-release/semantic-release) as an unexpected error (i/o issue, code problem etc...). That indicate to the `semantic-release` process to stop, log the error and exit with the `1` failure code.
## Usage
```js
import SemanticReleaseError from "@semantic-release/error";
// Default
throw new SemanticReleaseError();
// With error message
throw new SemanticReleaseError("An error happened");
// With error message and error code
throw new SemanticReleaseError("An error happened", "ECODE");
// With error message, error code and details
throw new SemanticReleaseError("An error happened", "ECODE", "Here is some suggestions to solve this error.");
// With inheritance
class InheritedError extends SemanticReleaseError {
constructor(message, code, newProperty, details) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.code = code;
this.details = details;
this.newProperty = "newProperty";
}
}
throw new InheritedError("An error happened", "ECODE", "Here is some suggestions to solve this error.");
```