public static function generate($message = null, \CMain $APPLICATION = null)
    {
        if (null === $APPLICATION) {
            $APPLICATION = $GLOBALS['APPLICATION'];
        }

        if ($ex = $APPLICATION->GetException()) {
            throw new static($message ? $message . ': ' . $ex->GetString() : $ex->GetString());
        } else {
            throw new static($message ? $message : 'Unknown exception');
        }
    }