Skip to content

Commit 1f356a3

Browse files
authored
Move response body from main exception message to separate field and method. Add string representation of HTTP code. (#1032)
Co-authored-by: test <test>
1 parent 3c13ebe commit 1f356a3

7 files changed

+274
-78
lines changed

src/InstagramScraper/Exception/InstagramAgeRestrictedException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class InstagramAgeRestrictedException extends InstagramException
66
{
7-
public function __construct($message = "", $code = 403, $previous = null)
7+
public function __construct($message = "", $code = 403, $responseBody = "", $previous = null)
88
{
9-
parent::__construct($message, $code, $previous);
9+
parent::__construct($message, $code, $responseBody, $previous);
1010
}
1111
}

src/InstagramScraper/Exception/InstagramAuthException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class InstagramAuthException extends InstagramException
66
{
7-
public function __construct($message = "", $code = 401, $previous = null)
7+
public function __construct($message = "", $code = 401, $responseBody = "", $previous = null)
88
{
9-
parent::__construct($message, $code, $previous);
9+
parent::__construct($message, $code, $responseBody, $previous);
1010
}
1111
}

src/InstagramScraper/Exception/InstagramChallengeRecaptchaException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class InstagramChallengeRecaptchaException extends InstagramException
66
{
7-
public function __construct($message = "", $code = 400, $previous = null)
7+
public function __construct($message = "", $code = 400, $responseBody = "", $previous = null)
88
{
9-
parent::__construct($message, $code, $previous);
9+
parent::__construct($message, $code, $responseBody, $previous);
1010
}
1111
}

src/InstagramScraper/Exception/InstagramChallengeSubmitPhoneNumberException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class InstagramChallengeSubmitPhoneNumberException extends InstagramException
66
{
7-
public function __construct($message = "", $code = 400, $previous = null)
7+
public function __construct($message = "", $code = 400, $responseBody = "", $previous = null)
88
{
9-
parent::__construct($message, $code, $previous);
9+
parent::__construct($message, $code, $responseBody, $previous);
1010
}
1111
}

src/InstagramScraper/Exception/InstagramException.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44

55
class InstagramException extends \Exception
66
{
7-
public function __construct($message = "", $code = 500, $previous = null)
7+
protected $responseBody;
8+
9+
public function __construct($message = "", $code = 500, $responseBody = "", $previous = null)
810
{
911
parent::__construct($message, $code, $previous);
12+
$this->responseBody = responseBody;
13+
}
14+
15+
public function getResponseBody()
16+
{
17+
return $this->responseBody;
1018
}
1119
}

src/InstagramScraper/Exception/InstagramNotFoundException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class InstagramNotFoundException extends InstagramException
66
{
7-
public function __construct($message = "", $code = 404, $previous = null)
7+
public function __construct($message = "", $code = 404, $responseBody = "", $previous = null)
88
{
9-
parent::__construct($message, $code, $previous);
9+
parent::__construct($message, $code, $responseBody, $previous);
1010
}
1111
}

src/InstagramScraper/Instagram.php

Lines changed: 255 additions & 67 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)