Skip to content

Commit eb4a064

Browse files
committed
error messages changed
1 parent 44845f7 commit eb4a064

5 files changed

+15
-15
lines changed

src/exceptions/MessageConstantlyUnprocessable.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
namespace Lukasz93P\AsyncMessageChannel\exceptions;
66

77

8+
use Throwable;
9+
810
class MessageConstantlyUnprocessable extends MessageUnprocessable
911
{
10-
protected function generateMessage(): string
12+
protected function generateMessage(Throwable $reason): string
1113
{
12-
return 'Message has been marked as constantly unprocessable a it should not be delivered again.';
14+
return 'Message has been marked as constantly unprocessable a it should not be delivered again. Reason:' . PHP_EOL . $reason->getMessage();
1315
}
1416

1517
}

src/exceptions/MessageTemporaryUnprocessable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
namespace Lukasz93P\AsyncMessageChannel\exceptions;
66

77

8+
use Throwable;
9+
810
class MessageTemporaryUnprocessable extends MessageUnprocessable
911
{
10-
protected function generateMessage(): string
12+
protected function generateMessage(Throwable $reason): string
1113
{
12-
return 'Message has been marked as temporary unprocessable that means it should be delivered again until successful processing.';
14+
return 'Message has been marked as temporary unprocessable that means it should be delivered again until successful processing. Reason:'
15+
. PHP_EOL . $reason->getMessage();
1316
}
1417

1518
}

src/exceptions/MessageUnprocessable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static function fromReason(Throwable $reason): self
1616

1717
private function __construct($code = 0, Throwable $previous = null)
1818
{
19-
parent::__construct($this->generateMessage(), $code, $previous);
19+
parent::__construct($this->generateMessage($previous), $code, $previous);
2020
}
2121

22-
abstract protected function generateMessage(): string;
22+
abstract protected function generateMessage(Throwable $reason): string;
2323
}

src/exceptions/MultipleMessagesPublishingFailed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MultipleMessagesPublishingFailed extends MessagePublishingFailed
1111
{
1212
public static function fromReason(Throwable $reason): self
1313
{
14-
return new self('Publishing of one or more messages failed.', $reason->getCode(), $reason);
14+
return new self('Publishing of one or more messages failed. Reason:' . PHP_EOL . $reason->getMessage(), $reason->getCode(), $reason);
1515
}
1616

1717
}

src/exceptions/ProcessingOfAsynchronousMessageFailed.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99

1010
class ProcessingOfAsynchronousMessageFailed extends MessageChannelException
1111
{
12-
public static function fromMessageBody(string $messageBody): self
13-
{
14-
return new self(self::generateExceptionMessage($messageBody));
15-
}
16-
1712
public static function fromMessageBodyAndReason(string $messageBody, Throwable $reason): self
1813
{
19-
return new self(self::generateExceptionMessage($messageBody), $reason->getCode(), $reason);
14+
return new self(self::generateExceptionMessage($messageBody, $reason), $reason->getCode(), $reason);
2015
}
2116

22-
private static function generateExceptionMessage(string $messageBody): string
17+
private static function generateExceptionMessage(string $messageBody, Throwable $reason): string
2318
{
24-
return 'Throwable was thrown during processing asynchronous message. Message body:' . PHP_EOL . $messageBody;
19+
return 'Throwable was thrown during processing asynchronous message. Message body:' . PHP_EOL . $messageBody . PHP_EOL . "Reason: {$reason->getMessage()}";
2520
}
2621

2722
private function __construct($message = "", $code = 0, Throwable $previous = null)

0 commit comments

Comments
 (0)