This commit is contained in:
Daniil Gentili 2017-04-22 01:51:25 +02:00
parent a3e2744099
commit 6997826bf4
3 changed files with 7 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);