<commit_before>part of main;

/// This controller is completely arbitrary. You can choose to set up
/// your environment however you like!
class ErrorController {
  // lib/templates/error.chalk.html
  static const errorTemplate = 'error';

  Future<Response> general(
      Object exception,
      StackTrace stack) {
    print('<red>Uncaught error!\n$exception</red>');
    return _errorTemplate(exception, stack);
  }

  Future<Response> notFound(
      HttpNotFoundException exception,
      StackTrace stack) {
    return _errorTemplate(exception, stack, 404, {
      'message': "Oops! That page wasn't found!"
    });
  }

  Future<Response> _errorTemplate(
      Object exception,
      StackTrace stack,
      [int code = 500,
      Map<String, dynamic> variables = const {}]) async {

    // Create a template with the specified parameters
    final errorTemplate = await (template(errorTemplate, withData: variables)
      ..exception = exception
      ..stackTrace = stack
      ..code = code);

    // Return a shelf Response from the template and the params
    return new Response(
        code,
        body: errorTemplate.encoded,
        headers: {
          'Content-Type': ContentType.HTML.toString()
        });
  }
}<commit_msg>Converting to Response objects in Error Handlers no longer needed<commit_after>part of main;

/// This controller is completely arbitrary. You can choose to set up
/// your environment however you like!
class ErrorController {
  // lib/templates/error.chalk.html
  static const errorTemplate = 'error';

  general(Object exception, StackTrace stack) {
    print('<red>Uncaught error!\n$exception</red>');

    return template(errorTemplate)
      ..exception = exception
      ..stackTrace = stack
      ..code = 500;
  }

  notFound(HttpNotFoundException exception, StackTrace stack) {
    return template(errorTemplate)
      ..message = "Oops! That page wasn't found!"
      ..exception = exception
      ..stackTrace = stack
      ..code = 404;
  }
}
{'fraction_non_alphanumeric': 0.10339660339660339, 'fraction_numerical': 0.005994005994005994, 'mean_word_length': 2.9351669941060905, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4487623', 'n_tokens_mistral': 546, 'n_tokens_neox': 518, 'n_words': 172}