<commit_before><?php

# Enable PHP dev cli-server
if (php_sapi_name() === 'cli-server' && is_file(__DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI'])))
{
  return false;
}

include __DIR__ . '/../bootstrap.php';

define('IS_PRODUCTION', Request::getServerName() == 'lbry.io');

ini_set('display_errors', IS_PRODUCTION ? 'off' : 'on');
error_reporting(IS_PRODUCTION ? 0 : (E_ALL | E_STRICT));

register_shutdown_function('Controller::shutdown');

try
{
  i18n::register();
  Session::init();
  if (!IS_PRODUCTION)
  {
    View::compileCss();
  }
  Controller::dispatch(Request::getRelativeUri());
}
catch(Throwable $e)
{
  if (IS_PRODUCTION)
  {
    Slack::sendErrorIfProd($e);
    throw $e;
  }

  http_response_code(500);
  echo '<pre>'.Debug::exceptionToString($e).'</pre>';
}
<commit_msg>in dev, throw exceptions for warnings<commit_after><?php

# Enable PHP dev cli-server
if (php_sapi_name() === 'cli-server' && is_file(__DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI'])))
{
  return false;
}

include __DIR__ . '/../bootstrap.php';

define('IS_PRODUCTION', Request::getServerName() == 'lbry.io');

ini_set('display_errors', IS_PRODUCTION ? 'off' : 'on');
error_reporting(IS_PRODUCTION ? 0 : (E_ALL | E_STRICT));

register_shutdown_function('Controller::shutdown');

if (!IS_PRODUCTION)
{
  // make warnings into errors
  set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
    throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
  }, E_WARNING|E_CORE_WARNING|E_COMPILE_WARNING|E_USER_WARNING);
}

try
{
  i18n::register();
  Session::init();
  if (!IS_PRODUCTION)
  {
    View::compileCss();
  }
  Controller::dispatch(Request::getRelativeUri());
}
catch(Throwable $e)
{
  if (IS_PRODUCTION)
  {
    Slack::sendErrorIfProd($e);
    throw $e;
  }

  http_response_code(500);
  echo '<pre>'.Debug::exceptionToString($e).'</pre>';
}

{'fraction_non_alphanumeric': 0.1953414505029116, 'fraction_numerical': 0.006881948120698782, 'mean_word_length': 5.517241379310345, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3570559', 'n_tokens_mistral': 715, 'n_tokens_neox': 693, 'n_words': 112}