javascriptnode.jsgoogle-chromegoogle-apps-scriptpuppeteer

How to output to the console "SUCCESS" after a successful launch, and "ERROR" after an unsuccessful one?


The question is:

I'm currently working on Node.js with the Puppeteer library and I need to print "SUCCESS" to the console after a successful run and "ERROR" after a failed run. But I don't quite understand how to do it.

I will be grateful to everyone for help.


Solution

  • You could wrap the whole thing in a try...catch

    try {
      // Your Code Here
      console.log('Success');
    } catch (event) {
      console.error('Error');
    }