From 932ad65060f16140e4d23eafdd6a2f9c57a1f4e9 Mon Sep 17 00:00:00 2001 From: JochemKlingeler Date: Wed, 26 Sep 2018 22:10:38 +0200 Subject: [PATCH] Exception message now contains traceId to request debug information from Tikkie provider --- README.md | 2 +- src/Exceptions/PHPTikkieException.php | 4 +++- tests/CreatePaymentRequestTest.php | 2 +- tests/CreatePlatformTest.php | 2 +- tests/CreateUserTest.php | 2 +- tests/EnvironmentTest.php | 2 +- tests/FetchPaymentRequestTest.php | 2 +- tests/FetchPaymentRequestsTest.php | 2 +- tests/FetchPlatformsTest.php | 2 +- tests/FetchUsersTest.php | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8526b88..627e86a 100644 --- a/README.md +++ b/README.md @@ -117,5 +117,5 @@ use PHPTikkie\Exceptions\PHPTikkieException; try { var_dump($tikkie->platforms()); } catch (PHPTikkieException $exception) { - print $exception->getMessage(); // [ERR_2005_002] The API Key is invalid for the requested resource (see https://developer.abnamro.com/get-started#obtaining-an-api-key) + print $exception->getMessage(); // [ERR_2005_002] The API Key is invalid for the requested resource | traceId: 6fda2ce8-225d-4ca2-920a-b687c7aeb2f3 | (see https://developer.abnamro.com/get-started#obtaining-an-api-key) } diff --git a/src/Exceptions/PHPTikkieException.php b/src/Exceptions/PHPTikkieException.php index f7af415..20c68fe 100644 --- a/src/Exceptions/PHPTikkieException.php +++ b/src/Exceptions/PHPTikkieException.php @@ -22,7 +22,9 @@ public function __construct($message, $code = 0, Exception $previous = null) if (count($this->errors) > 0) { $error = $this->errors[0]; - $message = "[{$error->code}] {$error->message} (see {$error->reference})"; + $message = "[{$error->code}] {$error->message} " + . "| traceId: {$error->traceId} | " + . "(see {$error->reference})"; } } diff --git a/tests/CreatePaymentRequestTest.php b/tests/CreatePaymentRequestTest.php index 32bf30c..c128477 100644 --- a/tests/CreatePaymentRequestTest.php +++ b/tests/CreatePaymentRequestTest.php @@ -29,7 +29,7 @@ public function testCreatePaymentRequestFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->newPaymentRequest()->save(); } diff --git a/tests/CreatePlatformTest.php b/tests/CreatePlatformTest.php index f483cb9..d10eff4 100644 --- a/tests/CreatePlatformTest.php +++ b/tests/CreatePlatformTest.php @@ -33,7 +33,7 @@ public function testCreatePlatformFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->newPlatform()->save(); } diff --git a/tests/CreateUserTest.php b/tests/CreateUserTest.php index c458743..8f41d91 100644 --- a/tests/CreateUserTest.php +++ b/tests/CreateUserTest.php @@ -43,7 +43,7 @@ public function testCreateUserFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->newUser()->save(); } diff --git a/tests/EnvironmentTest.php b/tests/EnvironmentTest.php index 585cf0f..ad3ec3b 100644 --- a/tests/EnvironmentTest.php +++ b/tests/EnvironmentTest.php @@ -20,7 +20,7 @@ public function testInvalidApiKeyHandling() $this->setMockHttpResponse('InvalidApiKey.txt'); $this->expectException(AccessTokenException::class); - $this->expectExceptionMessage("[ERR_2005_001] The API Key is invalid (see https://developer.abnamro.com/get-started#obtaining-an-api-key)"); + $this->expectExceptionMessage("[ERR_2005_001] The API Key is invalid | traceId: 98de8459-377d-4834-a0a2-079f94f0f43d | (see https://developer.abnamro.com/get-started#obtaining-an-api-key)"); $this->tikkie->newPlatform()->save(); } diff --git a/tests/FetchPaymentRequestTest.php b/tests/FetchPaymentRequestTest.php index b3ee8a0..105bc2b 100644 --- a/tests/FetchPaymentRequestTest.php +++ b/tests/FetchPaymentRequestTest.php @@ -48,7 +48,7 @@ public function testFetchPaymentRequestFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->tikkie->paymentRequest('platformtoken1', 'usertoken1', 'paymentrequesttoken1'); } diff --git a/tests/FetchPaymentRequestsTest.php b/tests/FetchPaymentRequestsTest.php index a1a5727..a8d7ea3 100644 --- a/tests/FetchPaymentRequestsTest.php +++ b/tests/FetchPaymentRequestsTest.php @@ -58,7 +58,7 @@ public function testFetchPaymentRequestsFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->tikkie->paymentRequests('platformtoken1', 'usertoken1', 0, 10); } diff --git a/tests/FetchPlatformsTest.php b/tests/FetchPlatformsTest.php index 478c7ce..62d07ef 100644 --- a/tests/FetchPlatformsTest.php +++ b/tests/FetchPlatformsTest.php @@ -36,7 +36,7 @@ public function testFetchUsersFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->tikkie->platforms(); } diff --git a/tests/FetchUsersTest.php b/tests/FetchUsersTest.php index 4faab3d..dfe33f1 100644 --- a/tests/FetchUsersTest.php +++ b/tests/FetchUsersTest.php @@ -42,7 +42,7 @@ public function testFetchUsersFailed() $this->setMockHttpResponse(['AccessToken.txt', 'ValidationError.txt']); $this->expectException(RequestException::class); - $this->expectExceptionMessage("[ERR_1100_004] Field validation error (see https://developer.abnamro.com/api/tikkie/technical-details)"); + $this->expectExceptionMessage("[ERR_1100_004] Field validation error | traceId: 3cbf4bc9-108c-4e02-ad6e-937c79d875e3 | (see https://developer.abnamro.com/api/tikkie/technical-details)"); $this->tikkie->users('platformtoken1'); }