fix:修复安装模块时可能报异常的问题

This commit is contained in:
妙码生花 2023-07-18 03:28:18 +08:00
parent dfc6bd75ac
commit e5fa764873
2 changed files with 2 additions and 2 deletions

View File

@ -40,7 +40,7 @@ class Server
}
if (str_starts_with($content, '{')) {
$json = (array)json_decode($content, true);
throw new Exception($json['msg'], $json['code'], $json['data']);
throw new Exception($json['msg'], $json['code'], $json['data'] ?? []);
}
} catch (TransferException $e) {
throw new Exception('package download failed', 0, ['msg' => $e->getMessage()]);

View File

@ -10,7 +10,7 @@ use think\Exception as E;
*/
class Exception extends E
{
public function __construct(protected $message, protected $code = 0, protected $data = '')
public function __construct(protected $message, protected $code = 0, protected $data = [])
{
parent::__construct($message, $code);
}