/** * Checks the MQTTResponse for errors and throws an exception, if * no errors are encountered, the MQTTResponse is returned. * * @param MQTTResponse $response * @return HttpResponse * @throws M2XException */ protected function handleResponse(MQTTResponse $response) { $this->lastResponse = $response; if ($response->success()) { return $response; } throw new M2XException($response); }
/** * Create the exception from a MQTTResponse object * * @param HttpResponse $response */ public function __construct(MQTTResponse $response) { $data = $response->json(); $this->response = $response; parent::__construct(current($data), $response->statusCode); }