File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -189,3 +189,21 @@ test.serial('should mantain the error inheritance inalterated', t => {
189189 t . true ( err instanceof Error ) ;
190190 t . is ( err . name , 'BadMethodError' ) ;
191191} ) ;
192+
193+ test . serial ( 'should create HttpError, and retain a prior cause' , t => {
194+ const priorErr = new Error ( 'foobar' ) ;
195+
196+ let err = new errors . HttpError ( priorErr , 'new message' ) ;
197+ t . is ( err . cause ( ) , priorErr ) ;
198+ t . is ( err . name , 'HttpError' ) ;
199+ t . is ( err . message , 'new message' ) ;
200+ t . is ( err . body . message , 'new message' ) ;
201+ t . is ( err . body . code , 'Error' ) ;
202+
203+ err = new errors . HttpError ( priorErr , { message : 'bazinga!' } ) ;
204+ t . is ( err . cause ( ) , priorErr ) ;
205+ t . is ( err . name , 'HttpError' ) ;
206+ t . is ( err . message , 'bazinga!' ) ;
207+ t . is ( err . body . message , 'bazinga!' ) ;
208+ t . is ( err . body . code , 'Error' ) ;
209+ } ) ;
You can’t perform that action at this time.
0 commit comments