handleError()

in src/linter.js [94:131]


  handleError(err, _console = console) {
    // The zip files contains invalid entries (likely path names using invalid
    // characters like '\\'), the linter can inspect the package but Firefox
    // would fail to load it.
    if (err instanceof InvalidZipFileError) {
      this.collector.addError({
        ...messages.INVALID_XPI_ENTRY,
        message: err.message,
      });
      this.print(_console);
      return true;
    }

    // The zip file contains multiple entries with the exact same file name.
    if (err instanceof DuplicateZipEntryError) {
      this.collector.addError(messages.DUPLICATE_XPI_ENTRY);
      this.print(_console);
      return true;
    }

    // The zip file fails to open successfully, the linter can't inspect it
    // at all.
    if (err.message.includes(constants.ZIP_LIB_CORRUPT_FILE_ERROR)) {
      this.collector.addError(messages.BAD_ZIPFILE);
      this.print(_console);
      return true;
    }

    if (this.config.stack === true) {
      _console.error(err.stack);
    } else {
      _console.error(this.chalk.red(err.message || err));
    }

    this.closeIO();

    return false;
  }