* @subpackage LiteSpeed/src
* @author LiteSpeed Technologies <info@litespeedtech.com>
defined('WPINC') || exit();
private static $CODE_SET = array(
'HTA_LOGIN_COOKIE_INVALID' => 4300, // .htaccess did not find.
'HTA_DNF' => 4500, // .htaccess did not find.
'HTA_BK' => 9010, // backup
'HTA_R' => 9041, // read htaccess
'HTA_W' => 9042, // write
'HTA_GET' => 9030, // failed to get
* Throw an error with msg
public static function t($code, $args = null)
throw new \Exception(self::msg($code, $args));
* Translate an error to description
public static function msg($code, $args = null)
sprintf(__('The setting %s is currently enabled.', 'litespeed-cache'), '<strong>' . Lang::title(Base::O_DEBUG_DISABLE_ALL) . '</strong>') .
is_network_admin() ? network_admin_url('admin.php?page=litespeed-toolbox') : admin_url('admin.php?page=litespeed-toolbox'),
__('Click here to change.', 'litespeed-cache'),
sprintf(__('You will need to set %s to use the online services.', 'litespeed-cache'), '<strong>' . Lang::title(Base::O_API_KEY) . '</strong>') .
Doc::learn_more(admin_url('admin.php?page=litespeed-general'), __('Click here to set.', 'litespeed-cache'), true, false, true);
case 'out_of_daily_quota':
$msg = __('You have used all of your daily quota for today.', 'litespeed-cache');
'https://docs.quic.cloud/billing/services/#daily-limits-on-free-quota-usage',
__('Learn more or purchase additional quota.', 'litespeed-cache'),
$msg = __('You have used all of your quota left for current service this month.', 'litespeed-cache');
'https://docs.quic.cloud/billing/services/#daily-limits-on-free-quota-usage',
__('Learn more or purchase additional quota.', 'litespeed-cache'),
case 'too_many_requested':
$msg = __('You have too many requested images, please try again in a few minutes.', 'litespeed-cache');
case 'too_many_notified':
$msg = __('You have images waiting to be pulled. Please wait for the automatic pull to complete, or pull them down manually now.', 'litespeed-cache');
$msg = __('The image list is empty.', 'litespeed-cache');
$msg = __('Not enough parameters. Please check if the domain key is set correctly', 'litespeed-cache');
$msg = __('There is proceeding queue not pulled yet.', 'litespeed-cache');
case strpos($code, 'unfinished_queue ') === 0:
__('There is proceeding queue not pulled yet. Queue info: %s.', 'litespeed-cache'),
'<code>' . substr($code, strlen('unfinished_queue ')) . '</code>'
$msg = __('The site is not a valid alias on QUIC.cloud.', 'litespeed-cache');
case 'site_not_registered':
$msg = __('The site is not registered on QUIC.cloud.', 'litespeed-cache');
$msg = __('The domain key is not correct. Please try to sync your domain key again.', 'litespeed-cache');
$msg = __('The current server is under heavy load.', 'litespeed-cache');
$msg = __('Online node needs to be redetected.', 'litespeed-cache');
$msg = __('Credits are not enough to proceed the current request.', 'litespeed-cache');
$msg = __('%s file not writable.', 'litespeed-cache');
$args = array('<code>' . $args . '</code>');
$msg = __('Could not find %1$s in %2$s.', 'litespeed-cache');
case 'HTA_LOGIN_COOKIE_INVALID':
$msg = sprintf(__('Invalid login cookie. Please check the %s file.', 'litespeed-cache'), '.htaccess');
$msg = sprintf(__('Failed to back up %s file, aborted changes.', 'litespeed-cache'), '.htaccess');
$msg = sprintf(__('%s file not readable.', 'litespeed-cache'), '.htaccess');
$msg = sprintf(__('%s file not writable.', 'litespeed-cache'), '.htaccess');
$msg = sprintf(__('Failed to get %s file contents.', 'litespeed-cache'), '.htaccess');
case 'failed_tb_creation':
$msg = __('Failed to create table %s! SQL: %s.', 'litespeed-cache');
$msg = __('Crawler disabled by the server admin.', 'litespeed-cache');
case 'try_later': // QC error code
$msg = __('Previous request too recent. Please try again later.', 'litespeed-cache');
case strpos($code, 'try_later ') === 0:
__('Previous request too recent. Please try again after %s.', 'litespeed-cache'),
'<code>' . Utility::readable_time(substr($code, strlen('try_later ')), 3600, true) . '</code>'
case 'waiting_for_approval':
$msg = __('Your application is waiting for approval.', 'litespeed-cache');
case 'callback_fail_hash':
$msg = __('The callback validation to your domain failed due to hash mismatch.', 'litespeed-cache');
$msg = __('The callback validation to your domain failed. Please make sure there is no firewall blocking our servers.', 'litespeed-cache');
case substr($code, 0, 14) === 'callback_fail ':
__('The callback validation to your domain failed. Please make sure there is no firewall blocking our servers. Response code: ', 'litespeed-cache') .
$msg = __('Your domain has been forbidden from using our services due to a previous policy violation.', 'litespeed-cache');
'You cannot remove this DNS zone, because it is still in use. Please update the domain\'s nameservers, then try to delete this zone again, otherwise your site will become inaccessible.',
$msg = __('Unknown error', 'litespeed-cache') . ': ' . $code;
$msg = is_array($args) ? vsprintf($msg, $args) : sprintf($msg, $args);
if (isset(self::$CODE_SET[$code])) {
$msg = 'ERROR ' . self::$CODE_SET[$code] . ': ' . $msg;