public function testExceptionMessageFormatting() { $message = 'The class %s, is not found!. Loading tried for %d times.'; $messageData = ['TestClass', 6]; $expectedMessage = vsprintf($message, $messageData); $e = RuntimeException::createByFormat($message, $messageData); $this->assertInstanceOf(RuntimeException::class, $e); $this->assertEquals($expectedMessage, $e->getMessage()); }
/** * Execute the prepared request and optionally returns the response * * @param bool $returnTransfer Returns the returned response * * @throws \BuildR\Foundation\Exception\RuntimeException * * @return array|\stdClass * * @codeCoverageIgnore */ public function execute($returnTransfer = TRUE) { //Need transfer return if ($returnTransfer === TRUE) { $this->setOption(CURLOPT_RETURNTRANSFER, 1); } $result = curl_exec($this->handler); //Error handling if (curl_errno($this->handler)) { $format = [curl_errno($this->handler), curl_error($this->handler)]; $this->close(); throw RuntimeException::createByFormat('Error executing request, error code: %s, Message: %s', $format); } return $result; }