Added getResponseBody method in IDPException

Problem:

Some providers are sending additional information when an error occurs,
which can't be accessed because property `$result` is protected.

Solution:

Data from this property can be accessed using `getResponseBody()` method.

Closes #185
oauth1test
Alexandru Guzinschi 2015-02-26 12:50:11 +02:00
parent a86dbd4e58
commit c0f8ebf920
2 changed files with 19 additions and 1 deletions

View File

@ -25,6 +25,11 @@ class IDPException extends \Exception
parent::__construct($message, $code);
}
public function getResponseBody()
{
return $this->result;
}
public function getType()
{
$result = 'Exception';

View File

@ -41,4 +41,17 @@ class IDPExceptionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('message: 404: message', (string)$exception);
}
}
public function testGetResponseBody()
{
$exception = new IDPException(array('error' => 'message', 'code' => 404));
$this->assertEquals(
[
'error' => 'message',
'code' => 404
],
$exception->getResponseBody()
);
}
}