File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 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 () {
1111 assert . ok ( util . isError ( createError ( 500 ) ) ) // eslint-disable-line node/no-deprecated-api
1212 } )
1313
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+
1434 describe ( 'when status 300' , function ( ) {
1535 before ( function ( ) {
1636 this . error = createError ( 300 )
You can’t perform that action at this time.
0 commit comments