title: how to pass variable in error
body: <p>Heyo,</p>
  
  <p>I have a following function </p>
  
  <pre><code>async function fnIsOnScreenOnce(img, desc,iCounter,client,repeatDelay=0) {
    await timeout(repeatDelay);
    let screenshot= await client.screenshot()
  
    let buf = new Buffer(screenshot.value, 'base64');
    let img1 = cv.imdecode(buf)
    let result = img1.matchTemplate(img, 5).minMaxLoc(); 
    result.screenshot=img1;
    if (result.maxVal &lt;= 0.65) {
        // Fail
        const msg = "Can't see object yet";
        throw new Error(result);
    }
          // All good
          console.log("result:"+result)
          logger.info("Found image on screen: "+desc);
          return result;
  }
  </code></pre>
  
  <p>Call of the function</p>
  
  <pre><code>function fnIsOnScreen(img,client, repeats = 5, desc, wait = 2000,repeatDelay) {
      logger.info("Looking for image on screen:" +desc +" with " + repeats + " repeats ");
      let iCounter = 0;
      let init = ()=&gt; timeout(wait).then((asd)=&gt;{
        const attempt = () =&gt; fnIsOnScreenOnce(img, desc, iCounter,client,repeatDelay).then((data=&gt;{
          let imagepath=fnMarkOnImage(data.screenshot,img,data,outputDir)
          let description={};
          description.action="Is image on screen ?";
          description.desc=desc;
          description.repeats=repeats;
          description.wait=wait;
          description.img=imagepath;
          description.message="is this correct element ? if is then it was found correctly";
          fnPushToOutputArray(description)
        return data;
        })).catch(err =&gt; {
                console.log(JSON.stringify(err));
                console.log(err);
                console.log(err.result);
                iCounter++;
                if (iCounter === repeats) {
                    // Failed, out of retries
                    logger.info("Object not found : " + desc);
                    return Promise.reject("Object not found : " + desc);
                }
                // Retry after waiting
                return attempt();
            });
            return attempt();      
      })
      return init();
  
  
  }
  </code></pre>
  
  <p>result object contains some date.
  On error result contains {} object with no values in it. I would need to get all the values. So how can i pass result object through throw new error to retrieve it in catch ?</p>