How to use the @loki/core.unwrapError 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 / renderer-aws-lambda / src / create-aws-lambda-renderer.js View on Github external
return mapLimit(event.stories, concurrency, async task => {
    try {
      const screenshot = await captureScreenshotForStory(target, {
        kind: task.kind,
        story: task.story,
        configuration: task.configuration,
        options: event.options,
      });
      return screenshot;
    } catch (error) {
      return { errorMessage: serializeError(unwrapError(error)) };
    }
  });
};
github oblador / loki / packages / target-chrome-core / src / create-chrome-target.js View on Github external
async function getStorybook() {
    const url = `${baseUrl}/iframe.html`;
    try {
      const tab = await launchStoriesTab(url);
      return tab.executeFunctionWithWindow(getStories);
    } catch (rawError) {
      const error = unwrapError(rawError);
      if (
        error instanceof TimeoutError ||
        (error instanceof FetchingURLsError && error.failedURLs.includes(url))
      ) {
        throw new ServerError(
          'Failed fetching stories because the server is down',
          `Try starting it with "yarn storybook" or pass the --port or --host arguments if it's not running at ${baseUrl}`
        );
      }
      throw error;
    }
  }
github oblador / loki / packages / runner / src / cli.js View on Github external
async function run() {
  const args = process.argv.slice(2);
  const argv = minimist(args);
  const command = argv._[0] || 'test';
  const executor = getExecutorForCommand(command);

  bold(`loki ${command} v${version}`);

  try {
    await executor(args);
  } catch (rawError) {
    const error = unwrapError(rawError);

    if (
      error instanceof MissingDependencyError ||
      error instanceof ServerError ||
      error instanceof ChromeError ||
      error instanceof FetchingURLsError
    ) {
      die(error.message, error.instructions);
    }

    const childProcessFailed =
      error.cmd &&
      error.stderr &&
      error.message.indexOf('Command failed: ') === 0;
    if (childProcessFailed) {
      die(error.stderr);