Jelajahi Sumber

Remove variable func call and some more curl error checks

Jordi Boggiano 10 tahun lalu
induk
melakukan
4e53428476

+ 8 - 2
src/Monolog/Handler/CubeHandler.php

@@ -116,7 +116,11 @@ class CubeHandler extends AbstractProcessingHandler
         $data['data'] = $record['context'];
         $data['data']['level'] = $record['level'];
 
-        $this->{'write'.$this->scheme}(json_encode($data));
+        if ($this->scheme === 'http') {
+            $this->writeHttp(json_encode($data));
+        } else {
+            $this->writeUdp(json_encode($data));
+        }
     }
 
     private function writeUdp($data)
@@ -140,6 +144,8 @@ class CubeHandler extends AbstractProcessingHandler
                 'Content-Length: ' . strlen('['.$data.']'))
         );
 
-        return curl_exec($this->httpConnection);
+        if (curl_exec($this->httpConnection) === false) {
+            throw new \RuntimeException(sprintf('Curl error (code %s): %s', curl_errno($ch), curl_error($ch)));
+        }
     }
 }

+ 3 - 1
src/Monolog/Handler/MandrillHandler.php

@@ -63,7 +63,9 @@ class MandrillHandler extends MailHandler
             'async' => false,
         )));
 
-        curl_exec($ch);
+        if (curl_exec($ch) === false) {
+            throw new \RuntimeException(sprintf('Curl error (code %s): %s', curl_errno($ch), curl_error($ch)));
+        }
         curl_close($ch);
     }
 }