Handle error and throw a new ResourceException.

@param  int    $type
@param  string $message
@param  string $file
@param  int    $line

@throws ResourceException
186409
protected function handleError($type, $message, $file, $line)
    {
        throw new ResourceException(sprintf(
            '%s: "%s" in %s on line %d',
            $type,
            $message,
            $file,
            $line
        ));
    }
670989
protected function createErrorException($message, $code, $file, $line)
    {
        return new ErrorException($message, $code, 0/* will be resolved */, $file, $line);
    }
528449
public function assertionHandler($file, $line, $code)
    {
        if ($this->convertAssertionErrorsToExceptions) {
          
          $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line);
    
          if ($this->throwAssertionExceptions) {
              throw $exception;
          } else {
              $this->fb($exception);
          }
        
        } else {
            $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line));
        }
    }
17012
public static function IncludeException($code, $string, $file, $line, $context)
	{
		// check for repressed errors
		if (error_reporting() == 0) return;
		
		$tmp1 = explode(")",$string);
		$tmp2 = explode("(",$tmp1[0]);
		$mfile = isset($tmp2[1]) ? $tmp2[1] : "";
		
		$msg = "Error $code: " .  ($mfile ? "Unable to include file: '" . $mfile . "'" : $string);
		
		throw new IncludeException($msg,$code);
	}
207587
public function errorHandler($errno, $errstr, $file, $line)
    {
        switch ($errno) {
            case E_USER_ERROR:
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
                $this->logger->addError($errstr, array($file, $line));
                exit();
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $this->logger->addWarning($errstr, array($file, $line));
                break;
            default:
                $this->logger->addInfo($errstr, array($file, $line));
                break;
        }
    }
12494
public function addError($message, ...$text): void
    {
        $this->add(self::TYPE_ERROR, $message, ...$text);
    }
1103804
private function handleCurlError($errno, $message)
    {
        $apiBase = $this->apiBase;
        switch ($errno) {
            case CURLE_COULDNT_CONNECT:
            case CURLE_COULDNT_RESOLVE_HOST:
            case CURLE_OPERATION_TIMEOUTED:
                $msg = 'Could not connect to MyAllocator (' . $apiBase . '). '
                     . 'Please check your internet connection and try again.';
                break;
            default:
                $msg = 'Unexpected error communicating with MyAllocator. '
                     . 'If this problem persists,  let us know at '
                     . 'support@myallocator.com.';
        }

        $msg .= "\n\n(Network error [errno $errno]: $message)";
        throw new ApiConnectionException($msg, $this->state);
    }
612972
public static function lastErrorMsg($file,$message,$data) {
		Console::writeLine(PHP_EOL."<error>The JSON file, ".$file.", wasn't loaded. The error: ".$message."</error>");
		if ($message == "Syntax error, malformed JSON") {
			Console::writeLine("");
			$parser = new JsonLint\JsonParser();
			$error  = $parser->lint($data);
			Console::writeError($error->getMessage(), false, true);
		}
	}
590497
static function handleError($errstr, $type = E_USER_ERROR)
    {
        self::set("errors", true);

        trigger_error($errstr, $type);
    }
1342014
private static function prepare( $type, $message )
	{
		// to avoid typos and other mistakes we 
		// validate the alert type
		$type = strtolower( $type );
		if ( !in_array( $type, static::$_types ) ) 
		{
			throw new Exception( "UI\Alert - Unknown alert type '{$type}'!" );
		}

		// We always need to return an array
		if ( !is_array( $message ) )
		{
			return array( $message );
		}
		return $message;
	}
1082792
public function errorHandler($code, $message, $file, $line)
    {
        switch ($code) {
            case E_NOTICE:
            case E_USER_NOTICE:
                $exception = new Errors\Notice($message, $code, 1, $file, $line);
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $exception = new Errors\Warning($message, $code, 1, $file, $line);
                break;
            case E_ERROR:
            case E_CORE_ERROR:
            case E_RECOVERABLE_ERROR:
            case E_USER_ERROR:
                $exception = new Errors\Fatal($message, $code, 1, $file, $line);
                break;
            default:
                $exception = new Errors\Error($message, $code, 1, $file, $line);
                break;
        }

        $this->exceptionHandler($exception);

        if ($this->oldErrorHandler) {
            return call_user_func(
                $this->oldErrorHandler,
                $code,
                $message,
                $file,
                $line
            );
        }

        return false;
    }
818810
public function handler($number, $message, $file, $line, $context) {

		if(0 === error_reporting()) { 
			return;
		}

		$this -> error = new Error();
		$this -> error -> setFile($file); 
		$this -> error -> setMessage($message); 
		$this -> error -> setNumber($number); 
		$this -> error -> setLine($line); 
		$this -> error -> setDate(new DateTime()); 
		$this -> error -> setContext($context); 
		$this -> error -> setBacktrace(debug_backtrace(null, 5));
		$this -> error -> setIp(Request :: getIp());

		switch($this -> error -> getNumber()) {

			case E_ERROR :
			case E_CORE_ERROR :
			case E_COMPILE_ERROR :
			case E_PARSE :
				$this -> error -> setType('FATAL');
			break;
			
			case E_USER_ERROR :
			case E_RECOVERABLE_ERROR :
				$this -> error -> setType('ERROR');
			break;
		
			case E_WARNING :
			case E_CORE_WARNING :
			case E_COMPILE_WARNING :
			case E_USER_WARNING :
				$this -> error -> setType('WARNING');
			break;
		
			case E_NOTICE :
			case E_USER_NOTICE :
				$this -> error -> setType('INFO');
			break;
			
			case E_STRICT :
				$this -> error -> setType('STRICT');
			break;
		}

		$this -> action();
	}
795422
public function handleFatalError($code, $message, $file, $line)
    {
        error_log($message, 0);
        $this->handleException(new FatalErrorException($message, 500, $file, $line));

        return true;
    }
240032
protected static function renderHaltBody($type, $message, $line, $file)
    {
        $text = '<p><strong>Error Type: </strong>' . $type . '</p>' . '<p><strong>Info: </strong>' . nl2br($message) . '</p>' . '<p><strong>Line: </strong>' . $line . '</p>' . '<p><strong>File: </strong>' . $file . '</p>';
        $source = self::getSourceCode($file, $line);

        $sourceLen = strlen(strval(count($source['source']) + $source['first']));
        $padding = 40 + ($sourceLen - 1) * 8;
        if (!empty($source)) {
            $text .= '<style>' . file_get_contents(Helper::getComposerVendorPath() . '/scrivo/highlight.php/styles/github.css') . '</style>';
            $text .= '<style>
.source-code {
    padding: 6px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    overflow-x: auto;
}

.source-code pre {
    margin: 0;
}

.source-code pre ol {
    margin: 0;
    color: #4288ce;
    display: inline-block;
    min-width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
    padding-left: ' . $padding . 'px;
}

.source-code pre li {
    border-left: 1px solid #ddd;
    height: 18px;
    line-height: 18px;
}

.source-code pre code {
    color: #333;
    height: 100%;
    display: inline-block;
    border-left: 1px solid #fff;
    font-size: 14px;
    font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
}

.source-code pre li.line-error {
    background: #f8cbcb;
}

</style>';
            $text .= '<div class="source-code">
<pre id="code-block" class="hljs language-php">
    <ol start="' . $source['first'] . '">';
            $highlighter = new Highlighter();
            foreach ($source['source'] as $key => $value) {
                $currentLine = $key + $source['first'];
                $extendClass = ($currentLine == $line) ? ' line-error' : '';
                $text .= '<li class="line-' . $currentLine . $extendClass . '"><code>' . $highlighter->highlight('php', $value)->value . '</code></li>';
            }

            $text .= '</ol></pre></div>';
        }

        return $text;
    }
484518
public function throwException($message = '', $type = 'default')
    {
        switch ($type) {
            case 'access-denied':
                throw new AccessDeniedException($message);
            case 'not-found':
                throw new NotFoundHttpException($message);
            case 'runtime':
                throw new \RuntimeException($message);
            default:
                throw new \Exception($message);
        }
    }
791490
public static function error( $num, $message, $file, $line ) 
	{	
		$exception = new CCException( static::$error_types[$num]." - ".$message, 0, $num, $file, $line );
		
		if ( static::is_fatal_level( $num ) ) 
		{
			if ( static::$in_shutdown_process ) 
			{
				static::exception( $exception );
			} else 
			{
				throw $exception;
			}
		} else 
		{
			static::$non_fatals[] = $exception; 
		}
	}
1033580
public function setError($type, $message) {
        switch ($type) {
            case 'q':
                $this->error = array('QueryBuilderError' => $message);
                break;
            case 'd':
                $this->error = array('DatabaseError' => $message);
                break;
            default:
                $this->error = array('Error' => $message);
        }
    }