HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/lipovac/wp-content/plugins/the-events-calendar/common/src/Tribe/Exception.php
<?php


/**
 * Class Tribe__Exception
 *
 * Handles exceptions to log when not in debug mode.
 */
class Tribe__Exception extends Exception {

	/**
	 * @var Exception
	 */
	private $original_exception;

	/**
	 * Tribe__Exception constructor.
	 *
	 * @param Exception $original_exception
	 */
	public function __construct( Exception $original_exception ) {
		$this->original_exception = $original_exception;
	}

	/**
	 * Handles the exception throwing the original when debugging (`WP_DEBUG` defined and `true`)
	 * or quietly logging when `WP_DEBUG` is `false` or not set.
	 *
	 * @return bool  `true` if the message was logged, `false` otherwise.
	 *
	 * @throws Exception
	 */
	public function handle() {
		$debug = defined( 'WP_DEBUG' ) && WP_DEBUG;

		if ( $debug ) {
			$this->throw_original_exception();
		}

		return $this->log_original_exception_message();
	}

	/**
	 * @return string
	 */
	private function get_log_type_for_exception_code( $code ) {
		$map = array(
			// @todo: let's add a decent exception code to log type map here
		);

		return isset( $map[ $code ] ) ? $map[ $code ] : Tribe__Log::ERROR;
	}

	/**
	 * Throws the original exception.
	 *
	 * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
	 *
	 * @see Tribe__Exception::handle()
	 *
	 * @throws Exception
	 */
	public function throw_original_exception() {
		throw  $this->original_exception;
	}

	/**
	 * Logs the original exception message.
	 *
	 * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
	 *
	 * @see Tribe__Exception::handle()
	 *
	 * @return bool  `true` if the message was logged, `false` otherwise.
	 */
	private function log_original_exception_message() {
		if ( ! class_exists( 'Tribe__Log' ) ) {
			return false;
		}

		$logger   = new Tribe__Log();
		$message  = $this->original_exception->getMessage();
		$log_type = $this->get_log_type_for_exception_code( $this->original_exception->getCode() );
		$src      = $this->original_exception->getFile() . ':' . $this->original_exception->getLine();

		$logger->log( $message, $log_type, $src );

		return true;
	}
}