Skip to content

Commit f0338fa

Browse files
committed
small cleanup of Error
1 parent 8b3671e commit f0338fa

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/AbstractClient.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ protected function _newDeleteRequest(string $path, ?WriteOptions $opts): Request
108108
/**
109109
* @param \DCarbone\PHPConsulAPI\Request $r
110110
* @throws \GuzzleHttp\Exception\GuzzleException
111+
* @throws \Exception
111112
* @return \DCarbone\PHPConsulAPI\RequestResponse
112113
*/
113114
protected function _do(Request $r): RequestResponse
@@ -148,6 +149,7 @@ protected function _do(Request $r): RequestResponse
148149
/**
149150
* @param \DCarbone\PHPConsulAPI\RequestResponse $r
150151
* @param int $statusCode
152+
* @throws \Exception
151153
* @return \DCarbone\PHPConsulAPI\RequestResponse
152154
*/
153155
protected function _requireStatus(RequestResponse $r, int $statusCode): RequestResponse
@@ -195,6 +197,7 @@ protected function _requireStatus(RequestResponse $r, int $statusCode): RequestR
195197

196198
/**
197199
* @param \DCarbone\PHPConsulAPI\RequestResponse $r
200+
* @throws \Exception
198201
* @return \DCarbone\PHPConsulAPI\RequestResponse
199202
*/
200203
protected function _requireOK(RequestResponse $r): RequestResponse
@@ -250,6 +253,7 @@ protected function _doDelete(string $path, ?WriteOptions $opts): RequestResponse
250253

251254
/**
252255
* @param \Psr\Http\Message\StreamInterface $body
256+
* @throws \Exception
253257
* @return \DCarbone\PHPConsulAPI\DecodedBody
254258
*/
255259
protected function _decodeBody(StreamInterface $body): DecodedBody
@@ -277,6 +281,7 @@ protected function _decodeBody(StreamInterface $body): DecodedBody
277281
* @param mixed $body
278282
* @param \DCarbone\PHPConsulAPI\WriteOptions|null $opts
279283
* @throws \GuzzleHttp\Exception\GuzzleException
284+
* @throws \Exception
280285
* @return \DCarbone\PHPConsulAPI\WriteResponse
281286
*/
282287
protected function _executePut(string $path, $body, ?WriteOptions $opts): WriteResponse
@@ -291,6 +296,7 @@ protected function _executePut(string $path, $body, ?WriteOptions $opts): WriteR
291296
* @param string $path
292297
* @param \DCarbone\PHPConsulAPI\WriteOptions|null $opts
293298
* @throws \GuzzleHttp\Exception\GuzzleException
299+
* @throws \Exception
294300
* @return \DCarbone\PHPConsulAPI\WriteResponse
295301
*/
296302
protected function _executeDelete(string $path, ?WriteOptions $opts): WriteResponse
@@ -306,6 +312,7 @@ protected function _executeDelete(string $path, ?WriteOptions $opts): WriteRespo
306312
* @param mixed $body
307313
* @param \DCarbone\PHPConsulAPI\WriteOptions|null $opts
308314
* @throws \GuzzleHttp\Exception\GuzzleException
315+
* @throws \Exception
309316
* @return \DCarbone\PHPConsulAPI\ValuedWriteStringResponse
310317
*/
311318
protected function _doPutValuedStr(string $path, $body, ?WriteOptions $opts): ValuedWriteStringResponse
@@ -321,6 +328,7 @@ protected function _doPutValuedStr(string $path, $body, ?WriteOptions $opts): Va
321328
* @param string $path
322329
* @param \DCarbone\PHPConsulAPI\QueryOptions|null $opts
323330
* @throws \GuzzleHttp\Exception\GuzzleException
331+
* @throws \Exception
324332
* @return \DCarbone\PHPConsulAPI\ValuedQueryStringResponse
325333
*/
326334
protected function _doGetValuedStr(string $path, ?QueryOptions $opts): ValuedQueryStringResponse
@@ -336,6 +344,7 @@ protected function _doGetValuedStr(string $path, ?QueryOptions $opts): ValuedQue
336344
* @param string $path
337345
* @param \DCarbone\PHPConsulAPI\QueryOptions|null $opts
338346
* @throws \GuzzleHttp\Exception\GuzzleException
347+
* @throws \Exception
339348
* @return \DCarbone\PHPConsulAPI\ValuedQueryStringsResponse
340349
*/
341350
protected function _doGetValuedStrs(string $path, ?QueryOptions $opts): ValuedQueryStringsResponse
@@ -352,6 +361,7 @@ protected function _doGetValuedStrs(string $path, ?QueryOptions $opts): ValuedQu
352361
*
353362
* @param \DCarbone\PHPConsulAPI\RequestResponse $resp
354363
* @param \DCarbone\PHPConsulAPI\AbstractResponse $ret
364+
* @throws \Exception
355365
*/
356366
protected function _hydrateResponse(RequestResponse $resp, AbstractResponse $ret): void
357367
{

src/Error.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
*/
2828
class Error implements \JsonSerializable
2929
{
30+
private const FIELD_MESSAGE = 'message';
31+
private const FIELD_TIMESTAMP = 'timestamp';
32+
3033
/** @var \DCarbone\Go\Time\Time */
3134
private Time\Time $time;
3235

@@ -66,8 +69,8 @@ public function getMessage(): string
6669
public function jsonSerialize(): array
6770
{
6871
return [
69-
'message' => $this->message,
70-
'timestamp' => $this->time,
72+
self::FIELD_MESSAGE => $this->message,
73+
self::FIELD_TIMESTAMP => $this->time,
7174
];
7275
}
7376

0 commit comments

Comments
 (0)