public static function setExceptionHandler(ContainerInterface $container, string $context = '') /*: void*/
    {
        set_exception_handler(function(\Throwable $throwable) use ($container, $context) {
            $trace = $msg = null;
            try {
                $msg = rtrim(
                        get_class($throwable) . '(' . $throwable->getCode() . ')@' . $throwable->getFile() . ':'
                        . $throwable->getLine() . ': ' . addcslashes($throwable->getMessage(), "\0..\37"),
                        '.'
                    ) . '.';
                if ($container->has('inspect')) {
                    $trace = '' . $container->get('inspect')->trace($throwable);
                }
                if ($container->has('logger')) {
                    $container->get('logger')->error($trace ?? $throwable);
                }
            } catch (\Throwable $xcptn) {
                // Log original exception.
                if ($msg) {
                    error_log($msg);
                }
                // Log this exception handler's own exception.
                error_log(
                    get_class($xcptn) . '(' . $xcptn->getCode() . ')@' . $xcptn->getFile() . ':'
                    . $xcptn->getLine() . ': ' . addcslashes($xcptn->getMessage(), "\0..\37")
                );
            }
            switch ($context) {
                case 'http':
                    header('HTTP/1.1 500 Internal Server Error');
                    // Don't appear like PHP fatal error white-screen-of-death.
                    echo '<html><body><h1 style="font-family:sans-serif;color:darkblue">Internal Server Error</h1></body></html>';
                    exit;
                case 'cli':
                    echo "\033[01;31m[error]\033[0m " . ($trace ? ($msg . "\n- Check log.") : $throwable) . "\n";
                    break;
            }
        });
    }