File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,31 @@ var err = createError(404, 'This video does not exist!')
63
63
- ` message ` - the message of the error, defaulting to node's text for that status code.
64
64
- ` properties ` - custom properties to attach to the object
65
65
66
+ ### createError([ status] , [ error] , [ properties] )
67
+
68
+ Extend the given ` error ` object with ` createError.HttpError `
69
+ properties. This will not alter the inheritance of the given
70
+ ` error ` object, and the modified ` error ` object is the
71
+ return value.
72
+
73
+ <!-- eslint-disable no-redeclare, no-undef, no-unused-vars -->
74
+
75
+ ``` js
76
+ fs .readFile (' foo.txt' , function (err , buf ) {
77
+ if (err) {
78
+ if (err .code === ' ENOENT' ) {
79
+ var httpError = createError (404 , err, { expose: false })
80
+ } else {
81
+ var httpError = createError (500 , err)
82
+ }
83
+ }
84
+ })
85
+ ```
86
+
87
+ - ` status ` - the status code as a number
88
+ - ` error ` - the error object to extend
89
+ - ` properties ` - custom properties to attach to the object
90
+
66
91
### new createError\[ code || name\] (\[ msg] \) )
67
92
68
93
Create a new error object with the given message ` msg ` .
You can’t perform that action at this time.
0 commit comments