@@ -172,16 +172,16 @@ function wrapper(context) {
172
172
}
173
173
174
174
/**
175
- * @param {NodeJS.ErrnoException } err ann error
175
+ * @param {string } message an error message
176
176
* @param {number } status status
177
177
* @param {Partial<SendErrorOptions<Request, Response>>= } options options
178
178
* @returns {Promise<void> }
179
179
*/
180
- async function sendError ( err , status , options ) {
180
+ async function sendError ( message , status , options ) {
181
181
if ( forwardError ) {
182
182
const error =
183
183
/** @type {Error & { statusCode: number } } */
184
- ( new Error ( err . message ) ) ;
184
+ ( new Error ( message ) ) ;
185
185
error . statusCode = status ;
186
186
187
187
await goNext ( error ) ;
@@ -252,12 +252,12 @@ function wrapper(context) {
252
252
case "ENAMETOOLONG" :
253
253
case "ENOENT" :
254
254
case "ENOTDIR" :
255
- await sendError ( error , 404 , {
255
+ await sendError ( error . message , 404 , {
256
256
modifyResponseData : context . options . modifyResponseData ,
257
257
} ) ;
258
258
break ;
259
259
default :
260
- await sendError ( error , 500 , {
260
+ await sendError ( error . message , 500 , {
261
261
modifyResponseData : context . options . modifyResponseData ,
262
262
} ) ;
263
263
break ;
@@ -512,9 +512,7 @@ function wrapper(context) {
512
512
}
513
513
514
514
await sendError (
515
- extra . errorCode === 400
516
- ? new Error ( "Bad Request" )
517
- : new Error ( "Forbidden" ) ,
515
+ extra . errorCode === 400 ? "Bad Request" : "Forbidden" ,
518
516
extra . errorCode ,
519
517
{
520
518
modifyResponseData : context . options . modifyResponseData ,
@@ -708,7 +706,7 @@ function wrapper(context) {
708
706
// Conditional GET support
709
707
if ( isConditionalGET ( ) ) {
710
708
if ( isPreconditionFailure ( ) ) {
711
- await sendError ( new Error ( "Precondition Failed" ) , 412 , {
709
+ await sendError ( "Precondition Failed" , 412 , {
712
710
modifyResponseData : context . options . modifyResponseData ,
713
711
} ) ;
714
712
return ;
@@ -760,7 +758,7 @@ function wrapper(context) {
760
758
getValueContentRangeHeader ( "bytes" , size ) ,
761
759
) ;
762
760
763
- await sendError ( new Error ( "Range Not Satisfiable" ) , 416 , {
761
+ await sendError ( "Range Not Satisfiable" , 416 , {
764
762
headers : {
765
763
"Content-Range" : getResponseHeader ( res , "Content-Range" ) ,
766
764
} ,
0 commit comments