public function processError($exception, $type = 'exception', $logonly = false, $forcelogtrace = false) {
		// log information 
		// error function is from the trait . It will log something if there is logger inited
		
		$this->countoferrors++;
		
		if ($this->countoferrors > 500) {
			// if there are so many errors then somethign went wrong. better to stop
			// as it can be some wrong loop 
			return false;
		}
		
		$this->error($exception->getMessage(),
			// set group and exception as context for logger. Logger will decide what to write to a file
			array(
				'group' => 'error|'.$type,
				'exception' => $exception, 
				'forcelogtrace' => $forcelogtrace,
				'extrainfo' => 'Request info: '.$this->getRequestInformation()));
		
		$this->actionOnError($exception,$type);

		// this condition can be used to log information about some exception but don't stop the app
		if ($logonly) {
			return true;
		}

		if (!$this->showwarningmessage && $type == 'warning') {
			// show nothing to a user in case of warning
			return true;
		}
		if (!$this->showfatalmessage && $type == 'fatal') {
			// show nothing to a user in case of fatal error
			return true;
		}

		// decide hot to show to a user based on requested format
		$format = $this->getViewFormat();

		if ($format != 'html' && $type == 'fatal'){
			// for fatal error no sense to display somethign if this is not html request
			return true;
		}
		
		// display error screen based on the format
		switch ($format) {
			case 'json' :
				$this->showJSON($exception);
				break;
			case 'xml':
				$this->showXML($exception);
				break;
			case 'http':
				$this->showHTTP($exception);
				break;
			default:
				$this->showHTML($exception);
		}
		
		// if error message is displayed then no sence to do somethig else.
		die();
	}