mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
Little fix in responseHandler switch case:
throwing exception prevents next code execution, so it was unnecessary to use breaks. And also use return in case that differs from 200
This commit is contained in:
parent
2d9cd57d2e
commit
30b4aa5e9a
@ -206,24 +206,18 @@ class RestClient
|
|||||||
$result = new \stdClass();
|
$result = new \stdClass();
|
||||||
// return response data as json if possible, raw if not
|
// return response data as json if possible, raw if not
|
||||||
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
|
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
|
|
||||||
break;
|
|
||||||
case 401:
|
|
||||||
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
|
|
||||||
break;
|
|
||||||
case 404:
|
|
||||||
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result->http_response_code = $httpResponseCode;
|
$result->http_response_code = $httpResponseCode;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
case 400:
|
||||||
|
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
|
||||||
|
case 401:
|
||||||
|
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
|
||||||
|
case 404:
|
||||||
|
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
|
||||||
|
default:
|
||||||
|
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user