Skip to content

Commit 73baa03

Browse files
committed
added functions in error and response for getting out the request in debug mode
1 parent ac95fe1 commit 73baa03

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/SparkPost/SparkPostException.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ class SparkPostException extends \Exception
1111
*/
1212
private $body = null;
1313

14+
/**
15+
* Array with the request values sent
16+
*/
17+
private $request;
18+
1419
/**
1520
* Sets up the custom exception and copies over original exception values.
1621
*
1722
* @param Exception $exception - the exception to be wrapped
1823
*/
19-
public function __construct(\Exception $exception)
24+
public function __construct(\Exception $exception, $request)
2025
{
26+
$this->request = $request;
27+
2128
$message = $exception->getMessage();
2229
$code = $exception->getCode();
2330
if ($exception instanceof HttpException) {
@@ -29,6 +36,15 @@ public function __construct(\Exception $exception)
2936
parent::__construct($message, $code, $exception->getPrevious());
3037
}
3138

39+
/**
40+
* Returns the request values sent
41+
*
42+
* @return Array $request
43+
*/
44+
public function getRequest() {
45+
return $this->request;
46+
}
47+
3248
/**
3349
* Returns the body.
3450
*

lib/SparkPost/SparkPostResponse.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Psr\Http\Message\ResponseInterface as ResponseInterface;
66
use Psr\Http\Message\StreamInterface as StreamInterface;
7+
use Psr\Http\Message\RequestInterface as RequestInterface;
78

89
class SparkPostResponse implements ResponseInterface
910
{
@@ -12,14 +13,29 @@ class SparkPostResponse implements ResponseInterface
1213
*/
1314
private $response;
1415

16+
/**
17+
* Array with the request values sent
18+
*/
19+
private $request;
20+
1521
/**
1622
* set the response to be wrapped.
1723
*
1824
* @param ResponseInterface $response
1925
*/
20-
public function __construct(ResponseInterface $response)
26+
public function __construct(ResponseInterface $response, $request)
2127
{
2228
$this->response = $response;
29+
$this->request = $request;
30+
}
31+
32+
/**
33+
* Returns the request values sent
34+
*
35+
* @return Array $request
36+
*/
37+
public function getRequest() {
38+
return $this->request;
2339
}
2440

2541
/**

0 commit comments

Comments
 (0)