feat(telegram): exception carrying permanent/retry_after flags
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Cf7stg;
|
||||
|
||||
final class TelegramException extends \Exception
|
||||
{
|
||||
private bool $permanent;
|
||||
private int $retry_after;
|
||||
|
||||
public function __construct(string $message, int $code = 0, bool $permanent = false, int $retry_after = 0)
|
||||
{
|
||||
parent::__construct($message, $code);
|
||||
$this->permanent = $permanent;
|
||||
$this->retry_after = max(0, $retry_after);
|
||||
}
|
||||
|
||||
public function is_permanent(): bool
|
||||
{
|
||||
return $this->permanent;
|
||||
}
|
||||
|
||||
public function retry_after(): int
|
||||
{
|
||||
return $this->retry_after;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user