Asserts that an error handling is configured in a way that is compatible
with code expecting error exceptions.

@param Isolator|null $isolator The isolator to use.

@throws ErrorHandlingConfigurationException If error handling is not configured correctly.
323855
public static function assertCompatibleHandler(Isolator $isolator = null)
    {
        $isolator = Isolator::get($isolator);
        $message = 'Error handling is incorrectly configured.';

        try {
            $isolator->trigger_error($message, E_USER_NOTICE);
        } catch (ErrorException $e) {
            if (
                $e->getMessage() === $message &&
                $e->getSeverity() === E_USER_NOTICE
            ) {
                return;
            }
        }

        throw new ErrorHandlingConfigurationException();
    }
595437
private function handleSentinelErrorResponse(NodeConnectionInterface $sentinel, ErrorResponseInterface $error)
    {
        if ($error->getErrorType() === 'IDONTKNOW') {
            throw new ConnectionException($sentinel, $error->getMessage());
        } else {
            throw new ServerException($error->getMessage());
        }
    }
1192217
public function handleError($error = null)
    {
        if ($this->logErrors === true) {
            $this->log($error);
            if ($this->client) {
                $this->log($this->client->__getLastRequest());
            }
        }
        throw new Exception($error);
    }
1202044
public function install()
    {
        if (0 === $this->isolator->error_reporting()) {
            throw new ErrorHandlingConfigurationException();
        }

        if ($this->isInstalled()) {
            throw new AlreadyInstalledException();
        }

        $this->stack->push($this);
    }
86018
protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ValidationHttpException($validator->errors());
        }

        parent::failedValidation($validator);
    }
459899
static void assertTrue(boolean condition, String internalErrorMesg)
  throws SFException
  {
    if (!condition)
    {
      throw new SFException(ErrorCode.INTERNAL_ERROR, internalErrorMesg);
    }
  }
1277623
public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false)
    {
        $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions;
        $this->throwAssertionExceptions = $throwAssertionExceptions;
        
        if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) {
            throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!');
        }
        
        return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler'));
    }
111835
public static function errorHandler($iError, $sMsg, $sFile, $sLine) {
		if (Tango::isStopError($iError)) {
			self::handler(new TangoException($sMsg, 2), FALSE);
		}
		return FALSE;
	}
1051820
public function addExceptionHandler($handler) {
        if ( ! $handler instanceof IExceptionHandler && ! is_callable($handler)) {
            throw new InvalidHandlerType(
                s('Exception handler must be a callable or an instance of %s.',
                    IExceptionHandler::class)
            );
        }

        if (is_callable($handler)) {
            $handler = $this->createExceptionHandler($handler);
        }

        $this->exceptionHandlers[] = $handler;
    }
675688
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = null)
    {
        // throwing an exception in an error handler will halt execution
        //   set the last error and continue
        $this->last_error = compact('errno', 'errstr', 'errfile', 'errline', 'errcontext');
    }
503508
protected function registerErrorHandler(&$config)
    {
        if (Zilf_ENABLE_ERROR_HANDLER) {
            if (!isset($config['components']['errorHandler']['class'])) {
                echo "Error: no errorHandler component is configured.\n";
                exit(1);
            }
            $this->set('errorHandler', $config['components']['errorHandler']);
            unset($config['components']['errorHandler']);
            $this->getErrorHandler()->register();
        }
    }
905946
public static function ExceptionErrorHandler($errno = 0, $errstr = null, $errfile = null, $errline = null)
    {
        // If error is suppressed with @, don't throw an exception
        if (error_reporting() === 0 || strpos($errstr, 'headers already sent') || ($errfile && strpos($errfile, 'vendor/amphp') !== false)) {
            return false;
        }

        throw new self($errstr, $errno, null, $errfile, $errline);
    }
753331
def setErrorHandler(self, errorhandler):
        
        class ErrorHandlerWrapper(ErrorHandler):
            def __init__(self, errorhandler):
                self.errorhandler = errorhandler
                self.last_exception = None

            def error(self, exception):
                if isinstance(exception, amplpython.AMPLException):
                    exception = AMPLException(exception)
                try:
                    self.errorhandler.error(exception)
                except Exception as e:
                    self.last_exception = e

            def warning(self, exception):
                if isinstance(exception, amplpython.AMPLException):
                    exception = AMPLException(exception)
                try:
                    self.errorhandler.warning(exception)
                except Exception as e:
                    self.last_exception = e

            def check(self):
                if self.last_exception is not None:
                    e, self.last_exception = self.last_exception, None
                    raise e

        errorhandler_wrapper = ErrorHandlerWrapper(errorhandler)

        class InnerErrorHandler(amplpython.ErrorHandler):
            def error(self, exception):
                errorhandler_wrapper.error(exception)

            def warning(self, exception):
                errorhandler_wrapper.warning(exception)

        self._errorhandler = errorhandler
        self._errorhandler_inner = InnerErrorHandler()
        self._errorhandler_wrapper = errorhandler_wrapper
        lock_and_call(
            lambda: self._impl.setErrorHandler(self._errorhandler_inner),
            self._lock
        )
522792
private void serveError(Status status, ErrorMessage.FailureReason reason, RequestHandler requestHandler) throws IOException {
    this.serveError(status, reason.getMessage(), requestHandler);
  }
1149898
protected function failedValidation(Validator $validator)
    {
        if ($this->isApiRequest()) {
            throw new ValidationException($validator, $this->getErrorCodes());
        }

        parent::failedValidation($validator);
    }
174034
public static function setupExceptionHandling() {
        $previous = set_exception_handler(self::$exceptionHandler=__CLASS__.'::handleException');

        /**
         * Detect entering of the script's shutdown phase to be capable of handling destructor exceptions during shutdown
         * differently and avoid otherwise fatal errors. Should be the very first function on the shutdown function stack.
         *
         * @see  http://php.net/manual/en/language.oop5.decon.php
         * @see  ErrorHandler::handleDestructorException()
         */
        register_shutdown_function(function() {
            self::$inShutdown = true;
        });
        return $previous;
    }
755078
public function initialize(IContainer $container, ErrorHandler $errorHandler) {
        $container->set([ErrorHandler::class, IErrorHandler::class], $errorHandler);

        $errorHandler->enableErrorHandling();
        $errorHandler->enableExceptionHandling();

        $errorHandler->addErrorHandler([$this, 'handleError']);
        $errorHandler->addExceptionHandler([$this, 'handleException']);
    }