File tree 1 file changed +20
-0
lines changed 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,26 @@ describe('createError(status)', function () {
11
11
assert . ok ( util . isError ( createError ( 500 ) ) ) // eslint-disable-line node/no-deprecated-api
12
12
} )
13
13
14
+ describe ( 'Extending Existing Errors with HTTP Properties' , function ( ) {
15
+ it ( 'should extend existing error without altering its prototype or replacing the object' , function ( ) {
16
+ var nativeError = new Error ( 'This is a test error' )
17
+
18
+ // Extend the error with HTTP semantics
19
+ var httpError = createError ( 404 , nativeError , { expose : false } )
20
+
21
+ assert . strictEqual ( httpError . status , 404 )
22
+ assert . strictEqual ( httpError . expose , false )
23
+
24
+ assert . strictEqual ( httpError . message , 'This is a test error' )
25
+
26
+ assert ( httpError instanceof Error )
27
+
28
+ assert . strictEqual ( Object . getPrototypeOf ( httpError ) , Error . prototype )
29
+
30
+ assert . strictEqual ( httpError , nativeError )
31
+ } )
32
+ } )
33
+
14
34
describe ( 'when status 300' , function ( ) {
15
35
before ( function ( ) {
16
36
this . error = createError ( 300 )
You can’t perform that action at this time.
0 commit comments