Send custom error messages

  • Hi,
    I am trying to send custom error from jsReport. It sends the error back with status code 500 and message as undefined. In beforeRender(), I added new Error("No data") and I was hoping I would catch an error with 'No data' message but I get back error with status code 500 and message as undefined. What can I do differently?

    Thank you,

    error in getting quarterly details report:{"_body":{},"status":500,"ok":false,"statusText":"Internal Server Error","headers":{"access-control-allow-origin":["*"],"date":["Wed"," 14 Feb 2018 17:23:32 GMT"],"etag":["W/"2b6-959FsY0YsdYAOKAAaPKwRYH3Oe0""],"connection":["keep-alive"],"x-powered-by":["Express"],"content-length":["694"],"content-type":["application/json; charset=utf-8"]},"type":2,"url":"http://localhost:3000/reporting/api/report"}

    if (body[0] === undefined){
               done(new Error("No data"));

  • The returned error response body is JSON. Parse is it and you get the following structure.

      message: 'Error during rendering report: No data',
      stack: 'Error: No data\n    at beforeRender (evalmachine.<anonymous>:2:10)\n    at evalmachine.<anonymous>:4:111\n    at ContextifyScript.Script.runInContext (vm.js:59:29)\n    at ContextifyScript.Script.runInNewContext (vm.js:65:15)\n    at Object.runInNewContext (vm.js:135:38)\n    at module.exports (E:\\work\\temp\\jsrtest\\node_modules\\jsreport-scripts\\lib\\scriptEvalChild.js:123:6)\n    at process.<anonymous> (E:\\work\\temp\\jsrtest\\node_modules\\script-manager\\lib\\worker-processes.js:48:36)\n    at emitTwo (events.js:125:13)\n    at process.emit (events.js:213:7)\n    at emit (internal/child_process.js:774:12)' 

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.