Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from JochemKlingeler/feature/includeTraceIdInEx…
Browse files Browse the repository at this point in the history
…ceptionMessage

Exception message now contains traceId
  • Loading branch information
jarnovanleeuwen authored Sep 27, 2018
2 parents c878a1f + 932ad65 commit a56f21f
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 3 additions & 1 deletion src/Exceptions/PHPTikkieException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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})";
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CreatePaymentRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CreatePlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CreateUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FetchPaymentRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FetchPaymentRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FetchPlatformsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FetchUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit a56f21f

Please sign in to comment.