PHP 8.2.31
Preview: ErrorHandler.php Size: 790 B
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/API/JSON/ErrorHandler.php

<?php declare(strict_types = 1);

namespace MailPoet\API\JSON;

if (!defined('ABSPATH')) exit;


use MailPoet\Exception;
use MailPoet\HttpAwareException;

class ErrorHandler {
  /** @var string[] */
  private $defaultErrors;

  public function __construct() {
    $this->defaultErrors = [
      Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet'),
    ];
  }

  public function convertToResponse(\Throwable $e): ErrorResponse {
    if ($e instanceof Exception) {
      $errors = $e->getErrors() ?: $this->defaultErrors;
      $statusCode = $e instanceof HttpAwareException ? $e->getHttpStatusCode() : Response::STATUS_UNKNOWN;
      return new ErrorResponse($errors, [], $statusCode);
    }
    return new ErrorResponse($this->defaultErrors, [], Response::STATUS_UNKNOWN);
  }
}

Directory Contents

Dirs: 2 × Files: 8

Name Size Perms Modified Actions
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
v1 DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
9.36 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.49 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
398 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
790 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
921 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.07 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
519 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).