Skip to content

Commit

Permalink
Fixing message in exception getMessage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Liljegren committed Oct 28, 2014
1 parent 53fef75 commit 1ad4d46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function __construct(\Tivoka\Client\Connection\WebSocket $connection, Req
}

protected function formatMessage() {
$method = $this->request->method;
$message = $this->getMessage();
$data = $this->request->errorData;
$method = $this->request->method;
$message = $this->request->errorMessage;
$data = $this->request->errorData;

$phpversion = explode('.', phpversion());

Expand All @@ -81,9 +81,9 @@ protected function formatMessage() {
$json_encode_flags = JSON_PRETTY_PRINT;
}

$output .= "\nData: " . json_encode($data, $json_encode_flags);
$output .= "\nError data: " . json_encode($data, $json_encode_flags);
}
$output .= "\nRequest: " . $this->request->request;
$output .= "\nOn request: " . $this->request->request;

return $output;
}
Expand Down
10 changes: 6 additions & 4 deletions tests/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ public function testUnspecifiedExceptionCode() {
public function testGetMessageWithData() {
try {
$connection = new Connection(array('webshop' => 22222));
$new_order = new ApiInstance('Order', null, $connection);
$new_order->set(array('language' => 'foo')); // Will not validate

// Make an invalid set call.
$connection->Context->set(array('webshop' => 'Bad shop'), true);
}
catch (Textalk\WebshopClient\Exception $e) {
$string = $e->getMessage();
$data = $e->getData();

$this->assertRegExp('/^Order.set: /', $string);
$this->assertInternalType('array', $data);
$this->assertRegExp('/^Context.set: Invalid params./', $string);
$this->assertRegExp('/Error data:/', $string);
$this->assertRegExp('/On request:/', $string);
}

$this->assertNotNull($e, 'A Textalk\WebshopClient\Exception should be thrown.');
Expand Down

0 comments on commit 1ad4d46

Please sign in to comment.