title: Express.JS: How handle errors with Busboy?
body: <p>I need to catch all error into on file event of busboy and pass the error to next function.</p>
  <p>I want also catch all busboy error and pass the error to next function.</p>
  <pre><code>import * as Busboy from 'busboy';
  
  uploadAction(req: Request, res: Response, next: NextFunction) {
      let busboy: busboy.Busboy;
      // Create a new busboy instance
      // from doc, busboy constructor can raise an exception
      try {
          busboy = new Busboy({ headers: req.headers });
      } catch (err) {
          return next(err);
      } 
             
      busboy.on('file', (fieldname, file, filename) =&gt; {
          try {
              // my logic here...  
              throw new Error('Foo');  
          } catch (error) {
              // emit error to standard busboy event
              busboy.emit('error', error);
          }   
      });
  
      // listen all busboy error
      busboy.on('error', (err: string) =&gt; { 
          // remove busboy pipe
          req.unpipe(busboy);
          
          // ???????????????????????????????????
          // copy from https://github.com/expressjs/multer/blob/master/lib/make-middleware.js#L50
          req.on('readable', req.read.bind(req));
          busboy.removeAllListeners();
  
          // send error to next function
          next(err);
      });
  
      req.pipe(busboy);
  }
  </code></pre>
  <p>the next function is a global error handler that elaborate the error and send a response, eg.:</p>
  <pre><code>app.use((err: Error, req: Request, res: Response, next: NextFunction) =&gt; {
      // some logic here...
      res.send({ error: error.message });
  });
  </code></pre>
  <p>Now, whitout the line</p>
  <pre><code>req.on('readable', req.read.bind(req));
  </code></pre>
  <p>into:</p>
  <pre><code>busboy.on('error', (err: string) =&gt; { 
      // remove busboy pipe
      req.unpipe(busboy);
          
      // ???????????????????????????????????
      // copy from https://github.com/expressjs/multer/blob/master/lib/make-middleware.js#L45
      req.on('readable', req.read.bind(req));
      busboy.removeAllListeners();
  
      // send error to next function
      next(err);
  });
  </code></pre>
  <p>the error handler can't send the response to the client..</p>
  <p>But what is the purpose of:</p>
  <pre><code>req.on('readable', req.read.bind(req));
  </code></pre>
  <p>In general: how handle correctly busboy error?</p>