<commit_before>'use strict'

module.exports = function (param, property, scope) {
  if (!scope) {
    scope = property
    property = param
    param = `${property}_id`
  }
  this.param(param, (req, res, next, id) => {
    if (!id) return next()
    scope().find(id).then((model) => {
      if (!model) return res.status(404).render('404')
      req[property] = res.locals[property] = model
      next()
    })
  })
}<commit_msg>Catch find errors.<commit_after>'use strict'

module.exports = function (param, property, scope) {
  if (!scope) {
    scope = property
    property = param
    param = `${property}_id`
  }
  this.param(param, (req, res, next, id) => {
    if (!id) return next()
    scope().find(id).then((model) => {
      if (!model) return res.status(404).render('404')
      req[property] = res.locals[property] = model
      next()
    }).catch(res.error)
  })
}
{'fraction_non_alphanumeric': 0.18295454545454545, 'fraction_numerical': 0.013636363636363636, 'mean_word_length': 3.041284403669725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6823233', 'n_tokens_mistral': 302, 'n_tokens_neox': 294, 'n_words': 69}