public function createService(Di $di)
    {
        $required = [
            'views_dir'    => null,
            'template_500' => null,
            'template_404' => null,
        ];

        $config = $di->get('config')['error_handler']->toArray();
        $errMsg = sprintf('Cannot create error handler "%s"', __CLASS__);
        if (!isset($config['options'])) {
            throw new InvalidArgumentException($errMsg);
        }

        $options  = array_merge($required, $config['options']);
        if (empty($options['views_dir']) || empty($options['template_500']) || empty($options['template_404']) ||
                ($realPath = realpath($options['views_dir'])) === false) {
            throw new InvalidArgumentException($errMsg);
        }

        $this->options  = $options;
        $this->di       = $di;
        $this->viewsDir = $realPath;
        return $this;
    }