Skip to content

Commit

Permalink
fix: exceptions fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
DEMAxx committed Jun 17, 2024
1 parent 3a704da commit ea2400f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/Exceptions/CdekException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
abstract class CdekException extends Exception
{
protected $code = 'cdek_error';
protected bool $isSchedule = false;
private ?array $data;

public function __construct(
Expand All @@ -26,7 +25,7 @@ public function __construct(
$this->data = $data ?? [];
$this->message = $message;

if ($stopPropagation && (defined('REST_REQUEST') || $this->isSchedule)) {
if ($stopPropagation && defined('REST_REQUEST')) {
wp_die($this->getWpError());
}

Expand Down
30 changes: 20 additions & 10 deletions src/Exceptions/CdekScheduledTaskException.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<?php

namespace Cdek\Exceptions;
class CdekScheduledTaskException extends \Cdek\Exceptions\CdekException
{
protected bool $isSchedule = true;
public function __construct(
string $message,
string $code = 'cdek_error',
?array $data = null
)
namespace {

defined('ABSPATH') or exit;
}

namespace Cdek\Exceptions{

use WP_Error;

class CdekScheduledTaskException
{
parent::__construct($message, $code, $data, true);
public function __construct(
string $message,
string $code = 'cdek_error',
?array $data = null
)
{
$error = new WP_Error('cdek_error', 'Error happened at CDEKDelivery');
$error->add($code, $message, $data);
wp_die($error);
}
}
}

0 comments on commit ea2400f

Please sign in to comment.