title: Not able to catch error from AWS sdk [S3]
body: <p>Im trying to download a file from S3 which doesn't exist on S3. I expect a error in this scenario and im also getting that error from aws-sdk i.e.</p>
  
  <p>**/vagrant/node_modules/aws-sdk/lib/request.js:31
  throw err;
  ^</p>
  
  <p>NoSuchKey: The specified key does not exist.**</p>
  
  <p>But the issue is, im not able to catch this error. If you check the code below, my listener request.on gets called and when i call reject in that the promise doesn't return from method downloadFontInfoFileFromS3 with reject.</p>
  
  <p>Is there any way i can catch the error and gracefully reject the promise from downloadFontInfoFileFromS3 function?</p>
  
  <pre><code>downloadFontInfoFileFromS3(fileKey) {
      return new Promise((resolve, reject) =&gt; {
          const sThree = new awsSDK.S3();
          const options = {
              Bucket: awsConf.bucket,
              Key: fileKey,
          };
          const downloadFilePath = SOME_PATH
          const file = fs.createWriteStream(downloadFilePath);
  
              const request = sThree.getObject(options);
  
              const download = request
                  .createReadStream().pipe(file);
  
              // called when error in aws-sdk
              request.on('error', (error) =&gt; {
                  logger.error('Failed to download file from S3:', error.message);
                  reject(error);
              });
  
              download.on('error', (error) =&gt; {
                  reject(error);
              });
  
              download.on('finish', () =&gt; {
                  resolve(downloadFilePath);
              });
              // the synchronous code that we want to catch thrown errors on
      });
  }
  </code></pre>