-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
128 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusFeedPlugin\Exception; | ||
|
||
use RuntimeException; | ||
use Throwable; | ||
|
||
final class GenerateBatchException extends RuntimeException implements ExceptionInterface | ||
{ | ||
private const DEFAULT_MESSAGE = 'An error occurred'; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $feedId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $channelCode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $localeCode; | ||
|
||
public function __construct(string $message, Throwable $previous) | ||
{ | ||
parent::__construct($message, 0, $previous); | ||
} | ||
|
||
public function getFeedId(): int | ||
{ | ||
return $this->feedId; | ||
} | ||
|
||
public function setFeedId(int $feedId): void | ||
{ | ||
$this->feedId = $feedId; | ||
|
||
$this->updateMessage(); | ||
} | ||
|
||
public function getChannelCode(): string | ||
{ | ||
return $this->channelCode; | ||
} | ||
|
||
public function setChannelCode(string $channelCode): void | ||
{ | ||
$this->channelCode = $channelCode; | ||
|
||
$this->updateMessage(); | ||
} | ||
|
||
public function getLocaleCode(): string | ||
{ | ||
return $this->localeCode; | ||
} | ||
|
||
public function setLocaleCode(string $localeCode): void | ||
{ | ||
$this->localeCode = $localeCode; | ||
|
||
$this->updateMessage(); | ||
} | ||
|
||
private function updateMessage(): void | ||
{ | ||
if(null !== $this->feedId) { | ||
$this->message .= ' | Feed: '.$this->feedId; | ||
} | ||
|
||
if(null !== $this->channelCode) { | ||
$this->message .= ' | Channel code: '.$this->channelCode; | ||
} | ||
|
||
if(null !== $this->localeCode) { | ||
$this->message .= ' | Locale code: '.$this->localeCode; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters