mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-21 21:44:46 +00:00
.
This commit is contained in:
parent
00c3b50fca
commit
ae5dcb46c8
7331 changed files with 1784502 additions and 0 deletions
77
node_modules/makeerror/readme.md
generated
vendored
Normal file
77
node_modules/makeerror/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
makeerror [](http://travis-ci.org/nshah/nodejs-makeerror)
|
||||
=========
|
||||
|
||||
A library to make errors.
|
||||
|
||||
|
||||
Basics
|
||||
------
|
||||
|
||||
Makes an Error constructor function with the signature below. All arguments are
|
||||
optional, and if the first argument is not a `String`, it will be assumed to be
|
||||
`data`:
|
||||
|
||||
```javascript
|
||||
function(message, data)
|
||||
```
|
||||
|
||||
You'll typically do something like:
|
||||
|
||||
```javascript
|
||||
var makeError = require('makeerror')
|
||||
var UnknownFileTypeError = makeError(
|
||||
'UnknownFileTypeError',
|
||||
'The specified type is not known.'
|
||||
)
|
||||
var er = UnknownFileTypeError()
|
||||
```
|
||||
|
||||
`er` will have a prototype chain that ensures:
|
||||
|
||||
```javascript
|
||||
er instanceof UnknownFileTypeError
|
||||
er instanceof Error
|
||||
```
|
||||
|
||||
|
||||
Templatized Error Messages
|
||||
--------------------------
|
||||
|
||||
There is support for simple string substitutions like:
|
||||
|
||||
```javascript
|
||||
var makeError = require('makeerror')
|
||||
var UnknownFileTypeError = makeError(
|
||||
'UnknownFileTypeError',
|
||||
'The specified type "{type}" is not known.'
|
||||
)
|
||||
var er = UnknownFileTypeError({ type: 'bmp' })
|
||||
```
|
||||
|
||||
Now `er.message` or `er.toString()` will return `'The specified type "bmp" is
|
||||
not known.'`.
|
||||
|
||||
|
||||
Prototype Hierarchies
|
||||
---------------------
|
||||
|
||||
You can create simple hierarchies as well using the `prototype` chain:
|
||||
|
||||
```javascript
|
||||
var makeError = require('makeerror')
|
||||
var ParentError = makeError('ParentError')
|
||||
var ChildError = makeError(
|
||||
'ChildError',
|
||||
'The child error.',
|
||||
{ proto: ParentError() }
|
||||
)
|
||||
var er = ChildError()
|
||||
```
|
||||
|
||||
`er` will have a prototype chain that ensures:
|
||||
|
||||
```javascript
|
||||
er instanceof ChildError
|
||||
er instanceof ParentError
|
||||
er instanceof Error
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue