<commit_before><?php
namespace Tango\Core;

Config::setFileDefault('exception', dirname(__DIR__).'/Config/exception.php');

class TangoException extends \Exception {

	static protected $_iDepth = 1;
	static protected $_sLastError = '';

	public function __construct($sMessage, $iDepth = 0, $iCode = 0) {

		$iDepth = (int)$iDepth;
		if ($iDepth < 0) {
			$iDepth = 0;
		}
		self::$_iDepth = $iDepth;

		parent::__construct($sMessage, $iCode);
	}

	static public function getLastError() {
		return self::$_sLastError;
	}

	static public function register() {
		set_exception_handler([__CLASS__, 'handler']);
		set_error_handler([__CLASS__, 'errorHandler']);
	}

	static public function handler(\Exception $e, $bSend = TRUE) {
		$s = "Uncaught exception: ".$e->getMessage();

		$aTrace = [];

		switch ((string)get_class($e)) {
			case __CLASS__:
				$lTrace = $e->getTrace();
				$aTrace = current($lTrace);
				if (!self::$_iDepth && !empty($lTrace[0]['class'])) {
					$sClass = $lTrace[0]['class'];
					foreach ($lTrace as $aRow) {
						if (empty($aRow['class']) || $aRow['class'] !== $sClass) {
							$aTrace = $aPrev;
							break;
						}
						$aPrev = $aRow;
					}
				} else {
					$aSelect =& $lTrace[self::$_iDepth - 1];
					if ($aSelect) {
						$aTrace = $aSelect;
					}
				}
				break;
			case 'ErrorException':
			default:
				$aTrace['file'] = $e->getFile();
				$aTrace['line'] = $e->getLine();
				break;
		}

		$aTrace += [

			'file' => '',
			'line' => 0,

			'type'   => '',
			'class'  => '',
			'function' => '',

			'args'   => '',<commit_msg>fix TangoException check<commit_after><?php
namespace Tango\Core;

Config::setFileDefault('exception', dirname(__DIR__).'/Config/exception.php');

class TangoException extends \Exception {

	static protected $_iDepth = 1;
	static protected $_sLastError = '';

	public function __construct($sMessage, $iDepth = 0, $iCode = 0) {

		$iDepth = (int)$iDepth;
		if ($iDepth < 0) {
			$iDepth = 0;
		}
		self::$_iDepth = $iDepth;

		parent::__construct($sMessage, $iCode);
	}

	static public function getLastError() {
		return self::$_sLastError;
	}

	static public function register() {
		set_exception_handler([__CLASS__, 'handler']);
		set_error_handler([__CLASS__, 'errorHandler']);
	}

	static public function handler(\Exception $e, $bSend = TRUE) {
		$s = "Uncaught exception: ".$e->getMessage();

		$aTrace = [];

		if (is_a($e, __CLASS__)) {

			$lTrace = $e->getTrace();
			$aTrace = current($lTrace);
			if (!self::$_iDepth && !empty($lTrace[0]['class'])) {
				$sClass = $lTrace[0]['class'];
				foreach ($lTrace as $aRow) {
					if (empty($aRow['class']) || $aRow['class'] !== $sClass) {
						$aTrace = $aPrev;
						break;
					}
					$aPrev = $aRow;
				}
			} else {
				$aSelect =& $lTrace[self::$_iDepth - 1];
				if ($aSelect) {
					$aTrace = $aSelect;
				}
			}

		} else {

			$aTrace['file'] = $e->getFile();
			$aTrace['line'] = $e->getLine();
		}

		$aTrace += [

			'file' => '',
			'line' => 0,

			'type'   => '',
			'class'  => '',
			'function' => '',

			'args'   => '',
{'fraction_non_alphanumeric': 0.20202020202020202, 'fraction_numerical': 0.005865102639296188, 'mean_word_length': 3.2937062937062938, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '745532', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1099, 'n_words': 219}