protected function _actionFail(DispatcherContext $context)
    {
        //Check an exception was passed
        if(!isset($context->param) && !$context->param instanceof \Exception)
        {
            throw new \InvalidArgumentException(
                "Action parameter 'exception' [Exception] is required"
            );
        }

        //Get the exception object
        $exception = $context->param;

        //If the error code does not correspond to a status message, use 500
        $code = $exception->getCode();
        if(!isset(HttpResponse::$status_messages[$code])) {
            $code = '500';
        }

        //Get the error message
        $message = $exception->getMessage();
        if(empty($message)) {
            $message = HttpResponse::$status_messages[$code];
        }

        //Store the exception in the context
        $context->exception = $exception;

        //Set the response status
        $context->response->setStatus($code , $message);

        //Send the response
        return $this->send($context);
    }