| @@ -2,9 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace ImageOptimization\Classes\Client; |
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | -use ImageOptimization\Modules\Oauth\Classes\Exceptions\Quota_Exceeded_Error; | |
| 6 | +use ImageOptimization\Classes\Exceptions\Quota_Exceeded_Error; | |
| 7 | +use ImageOptimization\Modules\Connect\Classes\Exceptions\Connection_Error; | |
| 7 | 8 | use ImageOptimization\Modules\Optimization\Classes\Exceptions\Bulk_Token_Expired_Error; |
| 8 | 9 | use ImageOptimization\Modules\Optimization\Classes\Exceptions\Image_Already_Optimized_Error; |
| 9 | 10 | use Throwable; |
| 10 | 11 | |
| @@ -19,9 +20,9 @@ | ||
| 19 | 20 | */ |
| 20 | 21 | private $response; |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | - * @throws Throwable|Quota_Exceeded_Error|Bulk_Token_Expired_Error|Image_Already_Optimized_Error | |
| 24 | + * @throws Throwable|Quota_Exceeded_Error|Bulk_Token_Expired_Error|Image_Already_Optimized_Error|Connection_Error | |
| 24 | 25 | */ |
| 25 | 26 | public function handle() { |
| 26 | 27 | if ( ! is_wp_error( $this->response ) ) { |
| 27 | 28 | return $this->response; |
| @@ -32,16 +33,19 @@ | ||
| 32 | 33 | if ( isset( $this->known_errors[ $message ] ) ) { |
| 33 | 34 | throw $this->known_errors[ $message ]; |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - throw new Exception( $message ); | |
| 37 | + throw new Exception( esc_html( $message ) ); | |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | public function __construct( $response ) { |
| 40 | 41 | $this->known_errors = [ |
| 41 | - 'user reached limit' => new Quota_Exceeded_Error( esc_html__( 'Plan quota reached', 'image-optimizer' ) ), | |
| 42 | - 'Bulk token expired' => new Bulk_Token_Expired_Error( esc_html__( 'Bulk token expired', 'image-optimizer' ) ), | |
| 43 | - 'Image already optimized' => new Image_Already_Optimized_Error( esc_html__( 'Image already optimized', 'image-optimizer' ) ), | |
| 42 | + 'user reached limit' => new Quota_Exceeded_Error( esc_html__( 'Plan quota reached', 'image-optimization' ) ), | |
| 43 | + 'Bulk token expired' => new Bulk_Token_Expired_Error( esc_html__( 'Bulk token expired', 'image-optimization' ) ), | |
| 44 | + 'bulk request reached limit' => new Bulk_Token_Expired_Error( esc_html__( 'Bulk token expired', 'image-optimization' ) ), | |
| 45 | + 'Image already optimized' => new Image_Already_Optimized_Error( esc_html__( 'Image already optimized', 'image-optimization' ) ), | |
| 46 | + 'Token Auth Guard Request Failed!: Invalid Token' => new Connection_Error( esc_html__( 'Connection error', 'image-optimization' ) ), | |
| 44 | 47 | ]; |
| 48 | + | |
| 45 | 49 | $this->response = $response; |
| 46 | 50 | } |
| 47 | 51 | } |