<commit_before>import * as raven from './raven';

export function ExtensionError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

ExtensionError.prototype = Object.create(Error.prototype);

export function LocalFileError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

LocalFileError.prototype = Object.create(ExtensionError.prototype);

export function NoFileAccessError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

NoFileAccessError.prototype = Object.create(ExtensionError.prototype);

export function RestrictedProtocolError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

RestrictedProtocolError.prototype = Object.create(ExtensionError.prototype);

export function BlockedSiteError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

BlockedSiteError.prototype = Object.create(ExtensionError.prototype);

export function AlreadyInjectedError(message) {
  Error.apply(this, [message]);
  this.message = message;
}

AlreadyInjectedError.prototype = Object.create(ExtensionError.prototype);

/**
 * Returns true if `err` is a recognized 'expected' error.
 */
function isKnownError(err) {
  return err instanceof ExtensionError;
}

const IGNORED_ERRORS = [
  // Errors that can happen when the tab is closed during injection
  /The tab was closed/,
  /No tab with id.*/,
  // Attempts to access pages for which Chrome does not allow scripting
  /Cannot access contents of.*/,
  /The extensions gallery cannot be scripted/,
];

/**<commit_msg>Simplify custom error definitions<commit_after>import * as raven from './raven';

export class ExtensionError extends Error {}

export class LocalFileError extends ExtensionError {}

export class NoFileAccessError extends ExtensionError {}

export class RestrictedProtocolError extends ExtensionError {}

export class BlockedSiteError extends ExtensionError {}

export class AlreadyInjectedError extends ExtensionError {}

/**
 * Returns true if `err` is a recognized 'expected' error.
 */
function isKnownError(err) {
  return err instanceof ExtensionError;
}

const IGNORED_ERRORS = [
  // Errors that can happen when the tab is closed during injection
  /The tab was closed/,
  /No tab with id.*/,
  // Attempts to access pages for which Chrome does not allow scripting
  /Cannot access contents of.*/,
  /The extensions gallery cannot be scripted/,
];

/**
{'fraction_non_alphanumeric': 0.09991742361684558, 'fraction_numerical': 0.0, 'mean_word_length': 4.852657004830918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2610222', 'n_tokens_mistral': 673, 'n_tokens_neox': 656, 'n_words': 215}