<commit_before>unless window.require?
  initializeModule = (module) ->
    try
      module.initializer(r, module)
      module.initialized = true
    catch error
      throw new r.ModuleInitializerException(module.name, error)

  r = window.require = (moduleName) ->
    module = r.cache[moduleName]
    if module?
      initializeModule(module) unless module.initialized
      module.exports
    else
      throw new r.MissingModuleException(moduleName)

  r.cache = {}

  r.register = (moduleName, initializer) ->
    r.cache[moduleName] = {
      name: moduleName,
      initializer: initializer,
      initialized: false,
      exports: null
    }

  
  class r.MissingModuleException
    constructor: (@moduleName) ->
      @message = "Cannot find module '#{@moduleName}'"

  # make it a real javascript error
  r.MissingModuleException.prototype = new Error()
  r.MissingModuleException.prototype.constructor = r.MissingModuleException

  class r.ModuleInitializerException
    constructor: (@moduleName, @innerException) ->
    @message = "Error initializing module '#{@moduleName}': " +
      @innerException

  # make it a real javascript error
  r.ModuleInitializerException.prototype = new Error()
  r.ModuleInitializerException.prototype.constructor =
    r.ModuleInitializerException

<commit_msg>improved error messages<commit_after>unless window.require?
  initializeModule = (module) ->
    try
      module.initializer(r, module)
      module.initialized = true
    catch error
      throw new r.ModuleInitializerException(module.name, error)

  r = window.require = (moduleName) ->
    module = r.cache[moduleName]
    if module?
      initializeModule(module) unless module.initialized
      module.exports
    else
      throw new r.MissingModuleException(moduleName)

  r.cache = {}

  r.register = (moduleName, initializer) ->
    r.cache[moduleName] = {
      name: moduleName,
      initializer: initializer,
      initialized: false,
      exports: null
    }

  
  class r.MissingModuleException
    constructor: (@moduleName) ->
      @message = "Cannot find module '#{@moduleName}'"
      console?.error(@message)

  # make it a real javascript error
  r.MissingModuleException.prototype = new Error()
  r.MissingModuleException.prototype.constructor = r.MissingModuleException

  class r.ModuleInitializerException
    constructor: (@moduleName, @innerException) ->
      @message = "Error initializing module '#{@moduleName}': " +
        @innerException
      console?.error(@message)

  # make it a real javascript error
  r.ModuleInitializerException.prototype = new Error()
  r.ModuleInitializerException.prototype.constructor =
    r.ModuleInitializerException


{'fraction_non_alphanumeric': 0.09636767976278725, 'fraction_numerical': 0.0, 'mean_word_length': 3.4173486088379708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7217948', 'n_tokens_mistral': 749, 'n_tokens_neox': 728, 'n_words': 176}