Dealing errors

@param  string $message
@param  int $code
@return $this
@throws LogicException if current $error_type is to throw exception
@access protected
197381
protected function throwError(/*# string */ $message, /*# int */ $code)
    {
        switch ($this->error_type) {
            case self::ERROR_WARNING:
                trigger_error($message, \E_USER_WARNING);
                break;
            case self::ERROR_EXCEPTION:
                throw new LogicException($message, $code);
            default:
                break;
        }
        return $this;
    }
986427
public function setErrorByCode($code)
    {
        if (is_numeric($code)) {
            $code = ShopgateLibraryException::getMessageFor($code);
        }
        $this->setNotValidMessage($code);

        return $this;
    }
185984
static function raise_error( $code, $message, $type, array $trace = null ){
		if( error_reporting() === 0 ){
			// suppressed with `@' operator
			return;
		}
		self::clear_error_handlers();
		if( is_null($trace) ){
			$trace = debug_backtrace();
			array_shift( $trace );
		}
		$callee = current( $trace ); 
		$Err = new PLUGError( $code, $type, $message, $callee['file'], $callee['line'], $trace );
		$Err->raise();
		self::set_error_handlers();
		return $Err;
	}
1250241
public function exception($message = 'Undefined Exception', $type = null, $code = null)
    {
        if ($type === null) {
            $type = $this->default_exception;
        } elseif ($type[0] == '_') {
            if ($this->default_exception == 'BaseException') {
                $type = 'Exception_'.substr($type, 1);
            } else {
                $type = $this->default_exception.'_'.substr($type, 1);
            }
        } elseif ($type != 'BaseException') {
            $type = $this->app->normalizeClassName($type, 'Exception');
        }

        // Localization support
        $message = $this->app->_($message);

        if ($type == 'Exception') {
            $type = 'BaseException';
        }

        $e = new $type($message, $code);
        if (!($e instanceof BaseException)) {
            throw $e;
        }
        $e->owner = $this;
        $e->app = $this->app;
        $e->api = $this->app; // compatibility with ATK 4.2 and lower
        $e->init();

        return $e;
    }
932127
protected function _error($message, $code, $exception = null, $context = [])
    {
        if (isset($this->_errorHandler)) {
            call_user_func($this->_errorHandler, $message, $code, $exception, $context);
            trigger_error('FQDB error handler function should die() or throw another exception!', E_ERROR);
        } else {
            throw new FQDBException($message, $code, $exception);
        }
    }
1106290
protected function setError($code, $message)
    {
        $this->error = new \OtherCode\Rest\Core\Error($code, $message);
    }
151730
public static function withErrorCode($errorCode, $message, $innerException= null)
	{
		$ex = new XPath2Exception( $message, $innerException );
		$ex->ErrorCode = $errorCode;
		return $ex;
	}
832033
public function withError($message)
    {
        if (is_array($message)) {
            $this->errorBag->setErrors($message);
        } else {
            $this->errorBag->add($message);
        }

        return $this;
    }
269426
public function error( $message, $code = null, $data = null )
    {
        if ( null === $code && isset( $this->errorCodes[$message] ) )
        {
            $code = $this->errorCodes[$message];
        }

        return $this->getResponse( 'error', (object) array(
            'code'      => $code,
            'message'   => $message,
            'data'      => $data,
        ) );
    }
600709
public function addError(
        int $p_code,
        $p_message = null,
        $p_type = \FreeFW\Core\Error::TYPE_ERROR,
        $p_field = null
    ) {
        $this->errors[] = new \FreeFW\Core\Error($p_code, $p_message, $p_type, $p_field);
        return $this;
    }
730650
public function setUnhandledError($code, $message = '')
    {
        $this->unhandledError = ($code == 0) ? false : true;
        $this->errorCode      = $code;
        $this->errorText      = $message;

        return $this;
    }
776096
protected function createHttpException($code, $message = null)
    {
        if ($code == 404) {
            $message = 'Entity not found';
        }

        $exception = new HttpException($message, $code);
        return $exception;
    }
1224883
public function error($msg, Token $token = null, $code = 0)
    {
        $error = new ParserException(
            Translator::gettext($msg),
            $token,
            $code
        );
        parent::error($error);
    }
560236
public static function throw(string $message, int $code = 1, string $type = '', string $secondMessage = '') {
        throw new static($message, $code, $type, $secondMessage);
    }
88368
protected function _createTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null)
    {
        return new TranslationException($message, $code, $previous, $subject, $translator);
    }
37333
protected function handleException($message, $statusCode, $errorType, $errorCode, $missingParameter, $rawOutput)
    {
        if ($statusCode === 400 && $errorCode == 4010) {
            $class = 'MissingParameter';
        } elseif (array_key_exists($statusCode, $this->excByStatusCode)) {
            $class = $this->excByStatusCode[$statusCode];
        } else {
            $class = 'Hubtel';
        }

        $class = '\\OVAC\\HubtelPayment\\Exception\\' . $class . 'Exception';
        $instance = new $class($message, $statusCode);
        $instance->setErrorCode($errorCode);
        $instance->setErrorType($errorType ?: $class);
        $instance->setMissingParameter($missingParameter);
        $instance->setRawOutput($rawOutput);

        return $instance;
    }
25834
public function setErrorMessage($message)
    {
        switch (gettype($message)) {
            case 'string':
                $this->errorMessage = trim($message);
                break;
            case 'array':
                $this->errorMessage = empty($message) ? '' : $message;
                break;
            default:
                $this->errorMessage = '';
                break;
        }

        return $this;
    }