Skip to content

Commit

Permalink
Add an exception being thrown when proxmox return status_code >= 400
Browse files Browse the repository at this point in the history
  • Loading branch information
keepwn committed Sep 20, 2018
1 parent 8726501 commit 3129107
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Exception/BadResponseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace ProxmoxVE\Exception;

class BadResponseException extends \RuntimeException
{
}
5 changes: 5 additions & 0 deletions src/Proxmox.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use GuzzleHttp\Psr7\Request;

use ProxmoxVE\Exception\AuthenticationException;
use ProxmoxVE\Exception\BadResponseException;

/**
* ProxmoxVE class. In order to interact with the proxmox server, the desired
Expand Down Expand Up @@ -154,6 +155,10 @@ private function processHttpResponse($response)
return null;
}

if($response->getStatusCode() >= 400) {
throw new BadResponseException($response->getReasonPhrase());
}

switch ($this->fakeType) {
case 'pngb64':
$base64 = base64_encode($response->getBody());
Expand Down

0 comments on commit 3129107

Please sign in to comment.