fast-proxy icon indicating copy to clipboard operation
fast-proxy copied to clipboard

allow for custom error handling

Open jcbain opened this issue 1 year ago • 0 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Currently, if an error is thrown when the proxied request is made, the error is handled by fast-proxy. It would be nice for an optional callback to be passed so that the error, req, and res can be exposed to the user and handled as they see fit.

Motivation

No response

Example

function handleErrors (err, req, res) {
   If(res.writableFinished === false) {
      if(err.code ===  'SOMETHING') {
         // some logic here
     }
   }
}
proxy(req, res, source, { onError: handleErrors })

jcbain avatar Aug 07 '23 22:08 jcbain