mirror of
https://github.com/actions/labeler
synced 2026-05-07 17:41:02 +02:00
build
This commit is contained in:
39
node_modules/make-error/README.md
generated
vendored
39
node_modules/make-error/README.md
generated
vendored
@@ -1,8 +1,9 @@
|
||||
# make-error [](http://travis-ci.org/JsCommunity/make-error)
|
||||
# make-error
|
||||
|
||||
[](https://npmjs.org/package/make-error) [](https://travis-ci.org/JsCommunity/make-error) [](https://packagephobia.now.sh/result?p=make-error) [](https://github.com/JsCommunity/make-error/commits/master)
|
||||
|
||||
> Make your own error types!
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Compatible Node & browsers
|
||||
@@ -23,7 +24,7 @@ Installation of the [npm package](https://npmjs.org/package/make-error):
|
||||
Then require the package:
|
||||
|
||||
```javascript
|
||||
var makeError = require('make-error');
|
||||
var makeError = require("make-error");
|
||||
```
|
||||
|
||||
### Browser
|
||||
@@ -39,40 +40,40 @@ You can directly use the build provided at [unpkg.com](https://unpkg.com):
|
||||
### Basic named error
|
||||
|
||||
```javascript
|
||||
var CustomError = makeError('CustomError')
|
||||
var CustomError = makeError("CustomError");
|
||||
|
||||
// Parameters are forwarded to the super class (here Error).
|
||||
throw new CustomError('a message')
|
||||
throw new CustomError("a message");
|
||||
```
|
||||
|
||||
### Advanced error class
|
||||
|
||||
```javascript
|
||||
function CustomError (customValue) {
|
||||
CustomError.super.call(this, 'custom error message')
|
||||
function CustomError(customValue) {
|
||||
CustomError.super.call(this, "custom error message");
|
||||
|
||||
this.customValue = customValue
|
||||
this.customValue = customValue;
|
||||
}
|
||||
makeError(CustomError)
|
||||
makeError(CustomError);
|
||||
|
||||
// Feel free to extend the prototype.
|
||||
CustomError.prototype.myMethod = function CustomError$myMethod () {
|
||||
console.log('CustomError.myMethod (%s, %s)', this.code, this.message)
|
||||
}
|
||||
CustomError.prototype.myMethod = function CustomError$myMethod() {
|
||||
console.log("CustomError.myMethod (%s, %s)", this.code, this.message);
|
||||
};
|
||||
|
||||
//-----
|
||||
|
||||
try {
|
||||
throw new CustomError(42)
|
||||
throw new CustomError(42);
|
||||
} catch (error) {
|
||||
error.myMethod()
|
||||
error.myMethod();
|
||||
}
|
||||
```
|
||||
|
||||
### Specialized error
|
||||
|
||||
```javascript
|
||||
var SpecializedError = makeError('SpecializedError', CustomError);
|
||||
var SpecializedError = makeError("SpecializedError", CustomError);
|
||||
|
||||
throw new SpecializedError(42);
|
||||
```
|
||||
@@ -82,11 +83,11 @@ throw new SpecializedError(42);
|
||||
> Best for ES2015+.
|
||||
|
||||
```javascript
|
||||
import {BaseError} from 'make-error'
|
||||
import { BaseError } from "make-error";
|
||||
|
||||
class CustomError extends BaseError {
|
||||
constructor () {
|
||||
super('custom error message')
|
||||
constructor() {
|
||||
super("custom error message");
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -97,7 +98,7 @@ class CustomError extends BaseError {
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are *very* welcomed, either on the documentation or on
|
||||
Contributions are _very_ welcomed, either on the documentation or on
|
||||
the code.
|
||||
|
||||
You may:
|
||||
|
||||
Reference in New Issue
Block a user