How to use the @loki/core.ChromeError function in @loki/core

To help you get started, we’ve selected a few @loki/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oblador / loki / packages / target-chrome-docker / src / create-chrome-docker-target.js View on Github external
);
    const { code, stdout, stderr } = await execute(dockerPath, args);
    if (code === 0) {
      dockerId = stdout;
      const logs = execute(dockerPath, ['logs', dockerId, '--follow']);
      let errorLogs = [];
      logs.stderr.on('data', chunk => {
        errorLogs.push(chunk);
      });

      host = await getNetworkHost(execute, dockerId);
      try {
        await waitOnCDPAvailable(host, port);
      } catch (error) {
        if (error.message === 'Timeout' && errorLogs.length !== 0) {
          throw new ChromeError(
            `Chrome failed to start with ${
              errorLogs.length === 1 ? 'error' : 'errors'
            } ${errorLogs
              .map(e => `"${e.toString('utf8').trim()}"`)
              .join(', ')}`
          );
        }
        throw error;
      } finally {
        if (logs.code === null && !logs.killed) {
          logs.kill();
        }
        errorLogs = null;
      }
      debug(`Docker started with id ${dockerId}`);
    } else {