Skip to content

Missing async/await on ErrorHandlingMiddleware #195

@Hulle107

Description

@Hulle107

Hej love the package so far.

But have found that you do not really do promise for Error Handling Middleware the same way as you do other middleware.
This is what I think could help in that regard.

Suggestion: index.js

383. // Execute error middleware
384. for (const err of this._errors) {
385.   if (response._state === 'done') break;
386.   // Promisify error middleware
387.   await new Promise(async (r) => {
388.     let rtn = await err(e, response._request, response, () => {
389.       r();
390.     });
391.     if (rtn) response.send(rtn); r();
392.   });
393. }
394. // end for

As seen you could implement it the same way as you do for other middleware.
IF there is a reason for not do it this way I really wanna know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions