Skip to content

Commit

Permalink
code cleanup, added return of message to Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephraim Härer committed Jul 3, 2020
1 parent 4c3f5c4 commit 0acb5cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Exception/SalesforceAuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function fromClientException(ClientException $e)
{
$responseString = $e->getResponse()->getBody()->getContents();
$responseData = json_decode($responseString, true);
$ret = new self(self::$errorMessage, $e->getResponse()->getStatusCode());
$ret = new self(self::$errorMessage . ': ' . $e->getMessage(), $e->getResponse()->getStatusCode());
$ret->setErrors($responseData);
return $ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/SalesforceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function fromClientException(ClientException $e)
{
$responseString = $e->getResponse()->getBody()->getContents();
$responseData = json_decode($responseString, true);
$ret = new self(self::$errorMessage, $e->getResponse()->getStatusCode());
$ret = new self(self::$errorMessage . ': ' . $e->getMessage(), $e->getResponse()->getStatusCode());
$ret->setErrors($responseData);
return $ret;
}
Expand Down
14 changes: 7 additions & 7 deletions src/SalesforceFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SalesforceFunctions
/**
* @var string
*/
const apiVersion = "v47.0";
const apiVersion = "v48.0";

/**
* @var string
Expand All @@ -30,7 +30,7 @@ class SalesforceFunctions
/**
* @var string
*/
protected $apiVersion = "v47.0";
protected $apiVersion = "v48.0";

/**
* SalesforceFunctions constructor.
Expand Down Expand Up @@ -149,7 +149,7 @@ public function retrieve($object, $field, $id)

$status = $request->getStatusCode();

if ($status != 200) {
if ($status !== 200) {
throw new SalesforceException(
"Error: call to URL {$url} failed with status {$status}, response: {$request->getReasonPhrase()}"
);
Expand Down Expand Up @@ -185,7 +185,7 @@ public function create($object, $data)
throw SalesforceException::fromClientException($e);
}

if ($status != 201) {
if ($status !== 201) {
throw new SalesforceException(
"Error: call to URL {$url} failed with status {$status}, response: {$request->getReasonPhrase()}"
);
Expand Down Expand Up @@ -223,7 +223,7 @@ public function update($object, $id, $data)

$status = $request->getStatusCode();

if ($status != 204) {
if ($status !== 204) {
throw new SalesforceException(
"Error: call to URL {$url} failed with status {$status}, response: {$request->getReasonPhrase()}"
);
Expand Down Expand Up @@ -261,7 +261,7 @@ public function upsert($object, $field, $id, $data)

$status = $request->getStatusCode();

if ($status != 204 && $status != 201) {
if ($status !== 204 && $status !== 201) {
throw new SalesforceException(
"Error: call to URL {$url} failed with status {$status}, response: {$request->getReasonPhrase()}"
);
Expand Down Expand Up @@ -294,7 +294,7 @@ public function delete($object, $id)

$status = $request->getStatusCode();

if ($status != 204) {
if ($status !== 204) {
throw new SalesforceException(
"Error: call to URL {$url} failed with status {$status}, response: {$request->getReasonPhrase()}"
);
Expand Down

0 comments on commit 0acb5cb

Please sign in to comment.