Permalink
Browse files

Enforce the handler is callable before calling it

  • Loading branch information...
1 parent 49143f3 commit 30b48f1231b041bfd363517a77a3a2ea02b1f576 @Seldaek committed Nov 4, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/Monolog/Handler/FingersCrossedHandler.php
@@ -79,10 +79,13 @@ public function handle(array $record)
$this->buffering = false;
}
if (!$this->handler instanceof HandlerInterface) {
+ if (!is_callable($this->handler)) {
+ throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
+ }
$this->handler = call_user_func($this->handler, $record, $this);
- }
- if (!$this->handler instanceof HandlerInterface) {
- throw new \RuntimeException("The factory callback should return a HandlerInterface");
+ if (!$this->handler instanceof HandlerInterface) {
+ throw new \RuntimeException("The factory callable should return a HandlerInterface");
+ }
}
$this->handler->handleBatch($this->buffer);
$this->buffer = array();

0 comments on commit 30b48f1

Please sign in to comment.