handles most fatal exceptions
13772
def checking_exceptions
      yield
    rescue Errno::EACCES => e
      $stderr.puts e
    rescue Errno::ENOENT => e
      $stderr.puts e
    rescue Errno::EEXIST => e
      $stderr.puts e
    rescue NoProjectDirectoryError => e
      $stderr.puts "#{e.directory} is not a tetra project directory, see \"tetra init\""
    rescue GitAlreadyInitedError
      $stderr.puts "This directory is already a tetra project"
    rescue ExecutionFailed => e
      $stderr.puts "Failed to run `#{e.commandline}` (exit status #{e.status})"
    rescue Interrupt
      $stderr.puts "Execution interrupted by the user"
    end
732304
public function shutdownHandler()
    {
        $error = error_get_last();

        if(!is_null($error)) {
            $this->exceptionHandler(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'], 0));
        }
    }
1366802
def _handle_run_exception(self, exc):
        
        self.raise_exception(exc, self._current_tups)

        if self.auto_fail:
            failed = set()
            for key, batch in iteritems(self._batches):
                # Only wipe out batches other than current for exit_on_exception
                if self.exit_on_exception or key == self._current_key:
                    for tup in batch:
                        self.fail(tup)
                        failed.add(tup.id)

            # Fail current batch or tick Tuple if we have one
            for tup in self._current_tups:
                if tup.id not in failed:
                    self.fail(tup)

            # Reset current batch info
            self._batches[self._current_key] = []
            self._current_key = None
260275
protected void handleFatalError (Object causer, Error error)
    {
        if (_fatalThrottle.throttleOp()) {
            throw error;
        }
        log.warning("Fatal error caused by '" + causer + "': " + error, error);
    }
711445
function handleExceptions (runHooks, timeout) {
    process.on('uncaughtException', err => onUncaught(err, runHooks, timeout));
}
1121216
@Override
    public void fatalError(SAXParseException exception) throws SAXException {
        if (reportErrors) print("fatal", exception);
        if (abortOnErrors) throw exception;
    }
136068
static public function catchFatal()
    {
        $error = error_get_last();
        if ($error["type"] == E_ERROR 
            || $error['type'] == E_PARSE 
            || $error['type'] == E_CORE_ERROR
            || $error['type'] == E_COMPILE_ERROR) {
            self::errorHandler($error["type"], $error["message"], $error["file"], $error["line"]);
            /**
              Put fatals in the error log as well as the debug log
              For good measure, put them in STDERR too. Try to
              ensure somebody notices.
            */
            $msg = $error['message']
                . ' Line ' . $error['line']
                . ', File ' . $error['file'];
            self::$logger->error($msg);
            file_put_contents('php://stderr', $msg, FILE_APPEND);
        }
    }
1322443
public function handleException($exception, array $error = null)
    {
        if (null === $error) {
            self::$exitCode = 255;
        }
        if (!$exception instanceof \Exception) {
            $exception = new FatalThrowableError($exception);
        }
        $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
        $handlerException = null;

        if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
            if (false !== strpos($message = $exception->getMessage(), "class@anonymous\0")) {
                $message = (new FlattenException())->setMessage($message)->getMessage();
            }
            if ($exception instanceof FatalErrorException) {
                if ($exception instanceof FatalThrowableError) {
                    $error = [
                        'type' => $type,
                        'message' => $message,
                        'file' => $exception->getFile(),
                        'line' => $exception->getLine(),
                    ];
                } else {
                    $message = 'Fatal '.$message;
                }
            } elseif ($exception instanceof \ErrorException) {
                $message = 'Uncaught '.$message;
            } else {
                $message = 'Uncaught Exception: '.$message;
            }
        }
        if ($this->loggedErrors & $type) {
            try {
                $this->loggers[$type][0]->log($this->loggers[$type][1], $message, ['exception' => $exception]);
            } catch (\Throwable $handlerException) {
            }
        }
        if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
            foreach ($this->getFatalErrorHandlers() as $handler) {
                if ($e = $handler->handleError($error, $exception)) {
                    $exception = $e;
                    break;
                }
            }
        }
        $exceptionHandler = $this->exceptionHandler;
        $this->exceptionHandler = null;
        try {
            if (null !== $exceptionHandler) {
                return $exceptionHandler($exception);
            }
            $handlerException = $handlerException ?: $exception;
        } catch (\Throwable $handlerException) {
        }
        if ($exception === $handlerException) {
            self::$reservedMemory = null; // Disable the fatal error handler
            throw $exception; // Give back $exception to the native handler
        }
        $this->handleException($handlerException);
    }
1240266
public function handleShutdown()
	{
		$error = error_get_last();

		// If an error has occurred that has not been displayed, we will create a fatal
		// error exception instance and pass it into the regular exception handling
		// code so it can be displayed back out to the developer for information.
		if ( ! is_null($error))
		{
			extract($error);

			if ( ! $this->isFatal($type)) return;

			$this->handleException(new FatalError($message, $type, 0, $file, $line))->send();
		}
	}
554348
public function handleShutdown()
	{
		$error = error_get_last();

		// If an error has occurred that has not been displayed, we will create a fatal
		// error exception instance and pass it into the regular exception handling
		// code so it can be displayed back out to the developer for information.
		if (!is_null($error))
		{
			extract($error);

			if (!in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE)))
			{
				return;
			}

			$this->handleException(new FatalError($message, $type, 0, $file, $line));
		}
	}
1281151
def handle_error(self):
        """"""
        if self.server.can_ignore_error(self):
            return
        if thread_local.status_code is None:
            msg("ERROR: Cannot send error status code! " +
                "Header already sent!\n{0}", traceback.format_exc())
        else:
            msg("ERROR: Error while processing request:\n{0}",
                traceback.format_exc())
            try:
                self.send_error(500, "Internal Error")
            except:  # nopep8
                if self.server.can_ignore_error(self):
                    return
                msg("ERROR: Cannot send error status code:\n{0}",
                    traceback.format_exc())
80533
public function onRequestTerminate() 
  {
    // lets see if there were unhandled fatal errors
    $lasterror=error_get_last();
    if(!is_null($lasterror)){
      if($lasterror['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)){
        // fatal error occured
        // increase memory limit so we we can at least complete our error handling (in case it was Allowed memory size exhausted)
        // (adding 1MB, unless already unlimited)
        $memlim=Web2All_PHP_INI::getBytes(ini_get('memory_limit'));
        if($memlim!=-1){
          ini_set('memory_limit',$memlim+1000000);
        }
        // then add this error to the observers
        $error = Web2All_Manager_Error::getInstance();
        $exception = new Web2All_Manager_TriggerException($lasterror['type'], $lasterror['message'], $lasterror['file'], $lasterror['line'], array());
        if ($error) {
          $error->setState($exception,$lasterror['type']);
        }
      }
    }
  }
871002
protected function handleShutdown()
    {
        if (! \is_null($error = \error_get_last()) && $this->isFatalError($error['type'])) {
            $this->handleUncaughtException(new FatalErrorException(
                $error['message'], $error['type'], 0, $error['file'], $error['line']
            ));
        }
    }
1349209
public function handleError($exception)
    {
        $errorMessage = ErrorHandler::getDetailedMessage($exception);
        $this->fatalError = $errorMessage;
        $this->vars['fatalError'] = $errorMessage;
    }
810657
public static function handleFatalError()
    {
        self::$reservedMemory = '';

        if (!$handler = self::$exceptionHandler) {
            return;
        }

        $error = error_get_last();

        if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
            $msg = sprintf('%s: %s', self::getErrorDescription($error['type']), $error['message']);

            if (strpos($error['message'], 'Allowed memory') === 0 || strpos($error['message'], 'Out of memory') === 0) {
                $exception = new ErrorException($msg, 0, $error['type'], $error['file'], $error['line']);
            } else {
                // @todo provide backtrace (through symfony/debug?)
                $exception = new ErrorException($msg, 0, $error['type'], $error['file'], $error['line']);
            }
        }

        if (!isset($exception)) {
            return;
        }

        try {
            $handler($exception);
        } catch (Exception $ex) {
            // Silence any further exceptions
        }
    }
434066
def handle_unhandled_exception(exc_type, exc_value, exc_traceback):
    """"""
    if issubclass(exc_type, KeyboardInterrupt):
        # call the default excepthook saved at __excepthook__
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return
    logger = logging.getLogger(__name__) # type: ignore
    logger.critical("Unhandled exception", exc_info=(exc_type, exc_value, exc_traceback))
5667
public void fatal(Object message, Throwable exception) {
    log(Level.FATAL, message, exception);
  }