src/Error/FormattedError.php
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;
    }
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;
    }
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