aboutsummaryrefslogtreecommitdiff
path: root/node_modules/makeerror/readme.md
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
commit080c5819d87b933816d724a83f3bf4f1686770a7 (patch)
tree4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/makeerror/readme.md
parent5ac7049a9d30733165cc212dee308163c2a14644 (diff)
parentd003b82235a9329f912522a2f70aa950dfce4998 (diff)
downloadLYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz
LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/makeerror/readme.md')
-rw-r--r--node_modules/makeerror/readme.md77
1 files changed, 77 insertions, 0 deletions
diff --git a/node_modules/makeerror/readme.md b/node_modules/makeerror/readme.md
new file mode 100644
index 0000000..f4f8eb1
--- /dev/null
+++ b/node_modules/makeerror/readme.md
@@ -0,0 +1,77 @@
+makeerror [![Build Status](https://secure.travis-ci.org/nshah/nodejs-makeerror.png)](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
+```