From 6997826bf47170c1e71fb1ce96e6ee8653530161 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 22 Apr 2017 01:51:25 +0200 Subject: [PATCH] fixes --- src/danog/MadelineProto/Exception.php | 10 +++++----- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 2 +- src/danog/MadelineProto/RPCErrorException.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/danog/MadelineProto/Exception.php b/src/danog/MadelineProto/Exception.php index 98962e6f..6163ff25 100644 --- a/src/danog/MadelineProto/Exception.php +++ b/src/danog/MadelineProto/Exception.php @@ -14,13 +14,15 @@ namespace danog\MadelineProto; class Exception extends \Exception { - public function __construct($message = null, $code = 0, Exception $previous = null) + public function __construct($message = null, $code = 0, Exception $previous = null, $file = null, $line = null) { parent::__construct($message, $code, $previous); if (\danog\MadelineProto\Logger::$constructed && $this->file !== __FILE__) { \danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR); } - \Rollbar\Rollbar::report_exception($this); + if ($line !== null) $this->line = $line; + if ($file !== null) $this->file = $file; + \Rollbar\Rollbar::log($this); } /** @@ -37,9 +39,7 @@ class Exception extends \Exception if (\danog\MadelineProto\Logger::$constructed) { \danog\MadelineProto\Logger::log([$errstr.' in '.basename($errfile).':'.$errline], \danog\MadelineProto\Logger::FATAL_ERROR); } - $e = new self($errstr, $errno); - $e->file = $errfile; - $e->line = $errline; + $e = new self($errstr, $errno, null, $errfile, $errline); throw $e; } } diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 79477f43..000d8196 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -28,7 +28,7 @@ trait CallHandler if (!isset($aargs['datacenter'])) { throw new \danog\MadelineProto\Exception('No datacenter provided'); } - if (isset($args['message']) && mb_strlen($args['message']) > 4096) { + if (isset($args['message']) && is_string($args['message']) && mb_strlen($args['message']) > 4096) { $message_chunks = $this->split_to_chunks($args['message']); $args['message'] = array_shift($message_chunks); } diff --git a/src/danog/MadelineProto/RPCErrorException.php b/src/danog/MadelineProto/RPCErrorException.php index 9c59e813..11065f5d 100644 --- a/src/danog/MadelineProto/RPCErrorException.php +++ b/src/danog/MadelineProto/RPCErrorException.php @@ -21,7 +21,7 @@ class RPCErrorException extends \Exception case 'CHANNEL_PRIVATE':$message = "You haven't joined this channel/supergroup"; break; case 'FLOOD_WAIT_666':$message = 'Spooky af m8'; break; case 'BOT_METHOD_INVALID':$message = 'This method cannot be run by a bot'; break; - default: \Rollbar\Rollbar::report_exception($this); + default: \Rollbar\Rollbar::log($this); } parent::__construct($message, $code, $previous);