-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Let the HTTP Producer return with 500 Internal Server error if not (all) jobs could be queued - Allow option to override response code and message for user exceptions
- Loading branch information
1 parent
522bde2
commit b9474e5
Showing
7 changed files
with
265 additions
and
38 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
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Webgriffe\Esb\Exception; | ||
|
||
class HttpResponseException extends \Exception | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $httpResponseCode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $clientMessage; | ||
|
||
/** | ||
* @param int $httpResponseCode The HTTP response code to use | ||
* @param string $clientMessage The message to send to the client | ||
* @param string $internalMessage The message to use internally (e.g. store in error logs), when empty the client message is used | ||
* @param int $code The Exception code. | ||
* @param \Throwable|null $previous The previous throwable used for the exception chaining. | ||
*/ | ||
public function __construct( | ||
int $httpResponseCode, | ||
string $clientMessage, | ||
string $internalMessage = "", | ||
int $code = 0, | ||
?\Throwable $previous = null | ||
) { | ||
$this->httpResponseCode = $httpResponseCode; | ||
$this->clientMessage = $clientMessage; | ||
parent::__construct($internalMessage ?: $clientMessage, $code, $previous); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getHttpResponseCode(): int | ||
{ | ||
return $this->httpResponseCode; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClientMessage(): string | ||
{ | ||
return $this->clientMessage; | ||
} | ||
} |
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
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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Webgriffe\Esb; | ||
|
||
class ProducerResult | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $jobsCount; | ||
|
||
/** | ||
* @var \Throwable|null | ||
*/ | ||
private $exception; | ||
|
||
/** | ||
* @param int $jobsCount | ||
* @param \Throwable|null $exception | ||
*/ | ||
public function __construct(int $jobsCount, ?\Throwable $exception = null) | ||
{ | ||
$this->jobsCount = $jobsCount; | ||
$this->exception = $exception; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getJobsCount(): int | ||
{ | ||
return $this->jobsCount; | ||
} | ||
|
||
/** | ||
* @return \Throwable|null | ||
*/ | ||
public function getException(): ?\Throwable | ||
{ | ||
return $this->exception; | ||
} | ||
} |
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
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
Oops, something went wrong.