Publish failed response event.

@param string        $eventClass
@param string        $errorMessage
@param KernelContext $context

@return \Generator
12997
private static function publishThrowable(string $eventClass, string $errorMessage, KernelContext $context): \Generator
    {
        /**
         * @noinspection VariableFunctionsUsageInspection
         *
         * @var \ServiceBus\Services\Contracts\ExecutionFailedEvent $event
         */
        $event = \forward_static_call_array([$eventClass, 'create'], [$context->traceId(), $errorMessage]);

        yield $context->delivery($event);
    }
894181
protected function _renderError(KDispatcherContextInterface $context)
    {
        $request   = $context->request;
        $response  = $context->response;

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

        //Get the exception object
        if($context->param instanceof KEventException) {
            $exception = $context->param->getException();
        } else {
            $exception = $context->param;
        }

        //Make sure the output buffers are cleared
        $level = ob_get_level();
        while($level > 0) {
            ob_end_clean();
            $level--;
        }

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

            if(ini_get('display_errors')) {
                $message = $exception->getMessage();
            } else {
                $message = KHttpResponse::$status_messages[$code];
            }

            $message = $this->getObject('translator')->translate($message);

            $class = get_class($exception);
            $error = new $class($message, $exception->getCode());
            JErrorPage::render($error);

            JFactory::getApplication()->close(0);

            return false;
        }
        else
        {
            //Render the exception if debug mode is enabled or if we are returning json
            if(in_array($request->getFormat(), array('json', 'html')))
            {
                $config = array(
                    'request'  => $request,
                    'response' => $response
                );

                $result = $this->getObject('com:koowa.controller.error',  $config)
                    ->layout('default')
                    ->render($exception);

                $response->setContent($result);
            }
        }
    }
248184
public function withDefaultThrowableEvent(string $eventClass): self
    {
        if (false === \is_a($eventClass, ExecutionFailedEvent::class, true))
        {
            throw new InvalidEventType(
                \sprintf(
                    'Event class "%s" must implement "%s" interface',
                    $eventClass,
                    ExecutionFailedEvent::class
                )
            );
        }

        $defaultValidationFailedEvent = $this->defaultValidationFailedEvent;

        /**
         * @psalm-var class-string $eventClass
         * @psalm-var class-string|null $defaultValidationFailedEvent
         */

        return new self(
            $this->isEventListener,
            $this->isCommandHandler,
            $this->validationEnabled,
            $this->validationGroups,
            $defaultValidationFailedEvent,
            $eventClass
        );
    }
114074
protected function triggerError($status, \ErrorException $exception)
    {
        $this->result = false;
        $this->errorStatus = $status;
        $this->errorException = $exception;
        $this->error && call_user_func($this->error, $this, $status, $exception);
    }
713567
private void handleError(final String errorMessage) {
		
		failed = true;
		
		switch (errorPolicy) {
		case LOG_ONLY:
			logger.error(errorMessage);
			break;
			
		case RUNTIME_EXCEPTION:
			throw new RuntimeException(errorMessage);

		default:
			logger.error("Got error {} but unkown error policy {}", errorMessage, errorPolicy);
			break;
		}
	}
25113
protected function throwNewInvalidArgumentException ($errorMsg) {
		$msgs = [];
		if ($this->field) 
			$msgs[] = 'Field name: `'.$this->field->GetName() . '`, Field type: `'.get_class($this->field).'`';
		if ($this->form) 
			$msgs[] = 'Form id: `'.$this->form->GetId() . '`, Form type: `'.get_class($this->form).'`';
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		throw new \InvalidArgumentException(
			'['.$selfClass.'] ' . $errorMsg . ($msgs ? ' '.implode(', ', $msgs) : '')
		);
	}
170502
protected static function createErrorReply(
        ContextInterface $context,
        $errorValue,
        int $errorCode,
        string $messageTemplate,
        array $messageParams
    ): array {
        return BlockReplies::createErrorReply($context, $errorValue, $errorCode, $messageTemplate, $messageParams);
    }
131420
public function triggerError($errorCode, $errorMessage = '')
    {
        $callError = $errorCode;

        if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) {
            if (isset($this->error[0]) && is_callable($this->error[0])) {
                $callError = 0;
            } else {
                // Nothing set to handle this error!
                return;
            }
        }

        // Error response function exists
        $this->match = true;

        //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage));
        $this->error[$callError]($errorCode, $errorMessage);
        // Or use call_user_func_array ?

        exit($errorCode);
    }
795648
protected function getErrorResponse(Exception $e, ErrorBag $errorBag)
    {
        switch (get_class($e)) {
            case ForbiddenException::class:
                $response = $this->forbidden($this->errorBag);
                break;
            case DataException::class:
                $response = $this->unprocessableEntity($errorBag);
                break;

            default:
                $response = $this->errorResponse(
                    new ErrorBag([new Error('Bad Request', 'Request could not be served.')])
                );
        }

        return $response;
    }
270801
public function run(MinimumStrictCoverage $minimumStrictCoverage, $errorMessage)
    {
        $currentCoverage = $this->strictCoverageProcessor->process();

        if ($minimumStrictCoverage->value() > $currentCoverage) {
            $this->output->writeln(BadJobLogoResponse::paint($errorMessage));

            throw new InvalidStrictCoverageException($currentCoverage, $minimumStrictCoverage->value());
        }

        return $currentCoverage;
    }
1330585
public void broadcastDDPError(String errorMsg) {
        // let core know there was an error subscribing to a collection
        Intent broadcastIntent = new Intent();
        broadcastIntent.setAction(MESSAGE_ERROR);
        broadcastIntent.putExtra(MESSAGE_EXTRA_MSG, errorMsg);
        LocalBroadcastManager.getInstance(mContext)
                .sendBroadcast(broadcastIntent);
    }
670841
public function error($errorCode = null, int $statusCode = null, $message = null):JsonResponse
    {
        if ($exception = config("responder.exceptions.$errorCode")) {
            if (class_exists($exception)) {
                throw new $exception();
            }
        }

        return $this->errorResponse->setError($errorCode, $message)->respond($statusCode);
    }
1053730
public static function failed(Phone $phone, Error $error, string $messageId = null): Result
    {
        return new self($phone, false, $messageId, $error);
    }
498877
protected function generateHttpError($errorCode = 404) {

		$content =
				'<h1>' .
				$errorCode .
				' ' .
				Response::$statusTexts[$errorCode] .
				'</h1>';

		Response::create($content, $errorCode)->send();
		exit();

	}
1022572
public function register($name, $class, $errorMessage = '', $labeledErrorMessage = '')
    {
        if (is_subclass_of($class, '\Sirius\Validation\Rule\AbstractRule')) {
            $this->validatorsMap[$name] = $class;
        }
        if ($errorMessage) {
            $this->errorMessages[$name] = $errorMessage;
        }
        if ($labeledErrorMessage) {
            $this->labeledErrorMessages[$name] = $labeledErrorMessage;
        }

        return $this;
    }
618418
public function setError($attribute, $errorMessage)
    {
        if (!isset($this->_errors[$attribute])) {
            $this->_errors[$attribute] = array();
        }
        $this->_errors[$attribute][] = $errorMessage;
        return $this;
    }
872498
public function errTrigger( $msg, $context, $level = E_WARNING ) {
		$die = false;
		$error = false;
		$notice = false;
		// Create $code string, decide error/die behaviour
		// and cast to USER constant as required by trigger_error().
		switch ( $level ) {
			// Fatal
			case E_ERROR:
			case E_USER_ERROR:
				$level = E_USER_ERROR;
				$code = 'Fatal error';
				$error = true;
				$die = true;
				break;

			// Warning
			case E_WARNING:
			case E_USER_WARNING:
				$level = E_USER_WARNING;
				$code = 'Warning';
				$error = true;
				break;

			// Notice
			case E_NOTICE:
			case E_USER_NOTICE:
				$level = E_USER_NOTICE;
				$code = 'Notice';
				$notice = true;
				break;

			// Unknown
			default:
				$code = 'Unknown error';
		}

		if ( $error && $this->suppressfatal ) {
			return;
		}
		if ( $notice && $this->suppressnotice ) {
			return;
		}

		$errorMsg = "$code: [$context] $msg";

		trigger_error( $errorMsg, $level );

		if ( $die && !$this->stayalive ) {
			die;
		}
	}