public function send(SendResponseEvent $event)
    {


        // Console //

        if ($this->response instanceof ConsoleResponse) {
            $templateContent = $this->getTemplateContent('console');
            // inject details
            $templateContent = $this->injectTemplateContent($templateContent, $event->getParams());
            $this->response->setContent($templateContent);
            $this->response->setErrorLevel(1);

            return $this->sendResponse($this->response);
        }


        // HTTP //

        $this->response->setStatusCode(500);

        $requestHeaders = $this->request->getHeaders();
        if ($requestHeaders->has('accept')) {

            $accept = $requestHeaders->get('Accept');
            $responseHeaders = $this->response->getHeaders();
            $responseHeaders->clearHeaders();

            if ($accept->match('text/html') !== false) { // html

                // get template content
                $templateContent = $this->getTemplateContent($event->getParam('type'));
                // inject details
                $templateContent = $this->injectTemplateContent($templateContent, $event->getParams());
                $contentType = 'text/html; charset=utf-8';
                $responseHeaders->addHeaderLine('content-type', $contentType);
                $this->response->setContent($templateContent);

            } else if ($accept->match('application/json') !== false
                || $accept->match('application/hal+json') !== false) { // json

                // return api problem structured json
                $contentType = 'application/problem+json; charset=utf-8';
                $responseHeaders->addHeaderLine('content-type', $contentType);
                // get template
                $templateContent = $this->getTemplateContent('json');
                // inject details
                $templateContent = $this->injectTemplateContent($templateContent, $event->getParams());
                $this->response->setContent($templateContent);

            }
        }

        $this->sendResponse($this->response);

    }