Skip to content

Commit

Permalink
AuthException
Browse files Browse the repository at this point in the history
  • Loading branch information
maztch committed Apr 18, 2017
1 parent ec9f5fa commit 5accf80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions src/Exceptions/AuthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Ilovepdf\Exceptions;

class AuthException extends \Exception {
class AuthException extends \Exception
{

private $params;
private $type;
Expand All @@ -14,26 +15,17 @@ public function __construct($message,
{
parent::__construct($message, $code, $previous);

$this->type = $response->body->error->type;
$this->type = $response->body->name;
$this->params = null;
}

public function getErrors() {

/*foreach($this->params as $key=>$error_param){
foreach($error_param as $single_param){
$errors[$key]=$single_param;
}
}*/
public function getErrors()
{
return $this->params;
}
public function getType() {

/*foreach($this->params as $key=>$error_param){
foreach($error_param as $single_param){
$errors[$key]=$single_param;
}
}*/
public function getType()
{
return $this->type;
}
}
2 changes: 1 addition & 1 deletion src/Ilovepdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function sendRequest($method, $endpoint, $body=null)
), $body);
if ($response->code != '200' && $response->code != '201') {
if ($response->code == 401) {
throw new AuthException($response->body->error->message, $response->code, null, $response);
throw new AuthException($response->body->name, $response->code, null, $response);
}

if ($endpoint == 'upload') {
Expand Down

0 comments on commit 5accf80

Please sign in to comment.