code: public static function prepareFormatter(?callable $formatter = null, $debug)
      {
          $formatter = $formatter ?: static function ($e) {
              return FormattedError::createFromException($e);
          };
          if ($debug) {
              $formatter = static function ($e) use ($formatter, $debug) {
                  return FormattedError::addDebugEntries($formatter($e), $e, $debug);
              };
          }
  
          return $formatter;
      }
docs: Prepares final error formatter taking in account $debug flags.
  If initial formatter is not set, FormattedError::createFromException is used
  
  @param  bool|int $debug
  
  @return callable|callable