PluginProbe ʕ •ᴥ•ʔ
LiteSpeed Cache / 7.6.1
LiteSpeed Cache v7.6.1
trunk 1.0.15 1.9.1.1 2.9.9.2 3.6.4 4.6 5.7.0.1 6.5.4 7.0.0.1 7.0.1 7.1 7.2 7.3 7.3.0.1 7.4 7.5 7.5.0.1 7.6 7.6.1 7.6.2 7.7 7.8 7.8.0.1 7.8.1
litespeed-cache / src / error.cls.php
litespeed-cache / src Last commit date
cdn 7 months ago data_structure 7 months ago activation.cls.php 7 months ago admin-display.cls.php 7 months ago admin-settings.cls.php 7 months ago admin.cls.php 7 months ago api.cls.php 7 months ago avatar.cls.php 7 months ago base.cls.php 7 months ago cdn.cls.php 7 months ago cloud.cls.php 7 months ago conf.cls.php 7 months ago control.cls.php 7 months ago core.cls.php 7 months ago crawler-map.cls.php 7 months ago crawler.cls.php 7 months ago css.cls.php 7 months ago data.cls.php 7 months ago data.upgrade.func.php 7 months ago db-optm.cls.php 7 months ago debug2.cls.php 7 months ago doc.cls.php 7 months ago error.cls.php 7 months ago esi.cls.php 7 months ago file.cls.php 7 months ago gui.cls.php 7 months ago health.cls.php 7 months ago htaccess.cls.php 7 months ago img-optm.cls.php 7 months ago import.cls.php 7 months ago import.preset.cls.php 7 months ago lang.cls.php 7 months ago localization.cls.php 7 months ago media.cls.php 7 months ago metabox.cls.php 7 months ago object-cache-wp.cls.php 7 months ago object-cache.cls.php 7 months ago object.lib.php 7 months ago optimize.cls.php 7 months ago optimizer.cls.php 7 months ago placeholder.cls.php 7 months ago purge.cls.php 7 months ago report.cls.php 7 months ago rest.cls.php 7 months ago root.cls.php 7 months ago router.cls.php 7 months ago str.cls.php 7 months ago tag.cls.php 7 months ago task.cls.php 7 months ago tool.cls.php 7 months ago ucss.cls.php 7 months ago utility.cls.php 7 months ago vary.cls.php 7 months ago vpi.cls.php 7 months ago
error.cls.php
254 lines
1 <?php
2 // phpcs:ignoreFile
3 /**
4 * The error class.
5 *
6 * @since 3.0
7 * @package LiteSpeed
8 */
9
10 namespace LiteSpeed;
11
12 defined( 'WPINC' ) || exit();
13
14 /**
15 * Class Error
16 *
17 * Handles error message translation and throwing for LiteSpeed Cache.
18 *
19 * @since 3.0
20 */
21 class Error {
22
23 /**
24 * Error code mappings to numeric values.
25 *
26 * @since 3.0
27 * @var array
28 */
29 private static $CODE_SET = array(
30 'HTA_LOGIN_COOKIE_INVALID' => 4300, // .htaccess did not find.
31 'HTA_DNF' => 4500, // .htaccess did not find.
32 'HTA_BK' => 9010, // backup
33 'HTA_R' => 9041, // read htaccess
34 'HTA_W' => 9042, // write
35 'HTA_GET' => 9030, // failed to get
36 );
37
38 /**
39 * Throw an error with message
40 *
41 * Throws an exception with the translated error message.
42 *
43 * @since 3.0
44 * @access public
45 * @param string $code Error code.
46 * @param mixed $args Optional arguments for message formatting.
47 * @throws \Exception Always throws an exception with the error message.
48 */
49 public static function t( $code, $args = null ) {
50 throw new \Exception( wp_kses_post( self::msg( $code, $args ) ) );
51 }
52
53 /**
54 * Translate an error to description
55 *
56 * Converts error codes to human-readable messages.
57 *
58 * @since 3.0
59 * @access public
60 * @param string $code Error code.
61 * @param mixed $args Optional arguments for message formatting.
62 * @return string Translated error message.
63 */
64 public static function msg( $code, $args = null ) {
65 switch ( $code ) {
66 case 'qc_setup_required':
67 $msg =
68 sprintf(
69 __( 'You will need to finish %s setup to use the online services.', 'litespeed-cache' ),
70 '<strong>QUIC.cloud</strong>'
71 ) .
72 Doc::learn_more(
73 admin_url( 'admin.php?page=litespeed-general' ),
74 __( 'Click here to set.', 'litespeed-cache' ),
75 true,
76 false,
77 true
78 );
79 break;
80
81 case 'out_of_daily_quota':
82 $msg = __( 'You have used all of your daily quota for today.', 'litespeed-cache' );
83 $msg .=
84 ' ' .
85 Doc::learn_more(
86 'https://docs.quic.cloud/billing/services/#daily-limits-on-free-quota-usage',
87 __( 'Learn more or purchase additional quota.', 'litespeed-cache' ),
88 false,
89 false,
90 true
91 );
92 break;
93
94 case 'out_of_quota':
95 $msg = __( 'You have used all of your quota left for current service this month.', 'litespeed-cache' );
96 $msg .=
97 ' ' .
98 Doc::learn_more(
99 'https://docs.quic.cloud/billing/services/#daily-limits-on-free-quota-usage',
100 __( 'Learn more or purchase additional quota.', 'litespeed-cache' ),
101 false,
102 false,
103 true
104 );
105 break;
106
107 case 'too_many_requested':
108 $msg = __( 'You have too many requested images, please try again in a few minutes.', 'litespeed-cache' );
109 break;
110
111 case 'too_many_notified':
112 $msg = __( 'You have images waiting to be pulled. Please wait for the automatic pull to complete, or pull them down manually now.', 'litespeed-cache' );
113 break;
114
115 case 'empty_list':
116 $msg = __( 'The image list is empty.', 'litespeed-cache' );
117 break;
118
119 case 'lack_of_param':
120 $msg = __( 'Not enough parameters. Please check if the QUIC.cloud connection is set correctly', 'litespeed-cache' );
121 break;
122
123 case 'unfinished_queue':
124 $msg = __( 'There is proceeding queue not pulled yet.', 'litespeed-cache' );
125 break;
126
127 case 0 === strpos( $code, 'unfinished_queue ' ):
128 $msg = sprintf(
129 __( 'There is proceeding queue not pulled yet. Queue info: %s.', 'litespeed-cache' ),
130 '<code>' . substr( $code, strlen( 'unfinished_queue ' ) ) . '</code>'
131 );
132 break;
133
134 case 'err_alias':
135 $msg = __( 'The site is not a valid alias on QUIC.cloud.', 'litespeed-cache' );
136 break;
137
138 case 'site_not_registered':
139 $msg = __( 'The site is not registered on QUIC.cloud.', 'litespeed-cache' );
140 break;
141
142 case 'err_key':
143 $msg = __( 'The QUIC.cloud connection is not correct. Please try to sync your QUIC.cloud connection again.', 'litespeed-cache' );
144 break;
145
146 case 'heavy_load':
147 $msg = __( 'The current server is under heavy load.', 'litespeed-cache' );
148 break;
149
150 case 'redetect_node':
151 $msg = __( 'Online node needs to be redetected.', 'litespeed-cache' );
152 break;
153
154 case 'err_overdraw':
155 $msg = __( 'Credits are not enough to proceed the current request.', 'litespeed-cache' );
156 break;
157
158 case 'W':
159 $msg = __( '%s file not writable.', 'litespeed-cache' );
160 break;
161
162 case 'HTA_DNF':
163 if ( ! is_array( $args ) ) {
164 $args = array( '<code>' . $args . '</code>' );
165 }
166 $args[] = '.htaccess';
167 $msg = __( 'Could not find %1$s in %2$s.', 'litespeed-cache' );
168 break;
169
170 case 'HTA_LOGIN_COOKIE_INVALID':
171 $msg = sprintf( __( 'Invalid login cookie. Please check the %s file.', 'litespeed-cache' ), '.htaccess' );
172 break;
173
174 case 'HTA_BK':
175 $msg = sprintf( __( 'Failed to back up %s file, aborted changes.', 'litespeed-cache' ), '.htaccess' );
176 break;
177
178 case 'HTA_R':
179 $msg = sprintf( __( '%s file not readable.', 'litespeed-cache' ), '.htaccess' );
180 break;
181
182 case 'HTA_W':
183 $msg = sprintf( __( '%s file not writable.', 'litespeed-cache' ), '.htaccess' );
184 break;
185
186 case 'HTA_GET':
187 $msg = sprintf( __( 'Failed to get %s file contents.', 'litespeed-cache' ), '.htaccess' );
188 break;
189
190 case 'failed_tb_creation':
191 $msg = __( 'Failed to create table %1$s! SQL: %2$s.', 'litespeed-cache' );
192 break;
193
194 case 'crawler_disabled':
195 $msg = __( 'Crawler disabled by the server admin.', 'litespeed-cache' );
196 break;
197
198 case 'try_later': // QC error code
199 $msg = __( 'Previous request too recent. Please try again later.', 'litespeed-cache' );
200 break;
201
202 case 0 === strpos( $code, 'try_later ' ):
203 $msg = sprintf(
204 __( 'Previous request too recent. Please try again after %s.', 'litespeed-cache' ),
205 '<code>' . Utility::readable_time( substr( $code, strlen( 'try_later ' ) ), 3600, true ) . '</code>'
206 );
207 break;
208
209 case 'waiting_for_approval':
210 $msg = __( 'Your application is waiting for approval.', 'litespeed-cache' );
211 break;
212
213 case 'callback_fail_hash':
214 $msg = __( 'The callback validation to your domain failed due to hash mismatch.', 'litespeed-cache' );
215 break;
216
217 case 'callback_fail':
218 $msg = __( 'The callback validation to your domain failed. Please make sure there is no firewall blocking our servers.', 'litespeed-cache' );
219 break;
220
221 case substr( $code, 0, 14 ) === 'callback_fail ':
222 $msg =
223 __( 'The callback validation to your domain failed. Please make sure there is no firewall blocking our servers. Response code: ', 'litespeed-cache' ) .
224 substr( $code, 14 );
225 break;
226
227 case 'forbidden':
228 $msg = __( 'Your domain has been forbidden from using our services due to a previous policy violation.', 'litespeed-cache' );
229 break;
230
231 case 'err_dns_active':
232 $msg = __(
233 '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.',
234 'litespeed-cache'
235 );
236 break;
237
238 default:
239 $msg = __( 'Unknown error', 'litespeed-cache' ) . ': ' . $code;
240 break;
241 }
242
243 if ( null !== $args ) {
244 $msg = is_array( $args ) ? vsprintf( $msg, $args ) : sprintf( $msg, $args );
245 }
246
247 if ( isset( self::$CODE_SET[ $code ] ) ) {
248 $msg = 'ERROR ' . self::$CODE_SET[ $code ] . ': ' . $msg;
249 }
250
251 return $msg;
252 }
253 }
254