catch Exception 改为 Throwable

This commit is contained in:
kuaifan 2022-05-13 15:58:06 +08:00
parent 279f05fd11
commit 99f9431794
8 changed files with 14 additions and 20 deletions

View File

@ -1151,7 +1151,7 @@ class ProjectController extends AbstractController
}
try {
Madzipper::make($zipPath)->add($xlsPath)->close();
} catch (\Exception) {
} catch (\Throwable) {
}
//
if (file_exists($zipPath)) {
@ -1386,7 +1386,7 @@ class ProjectController extends AbstractController
//
try {
ProjectTask::userTask($file->task_id, null);
} catch (\Exception $e) {
} catch (\Throwable $e) {
abort(403, $e->getMessage() ?: "This file not support download.");
}
//

View File

@ -661,7 +661,7 @@ class SystemController extends AbstractController
->html('<p>收到此电子邮件意味着您的邮箱配置正确。</p><p>Receiving this email means that your mailbox is configured correctly.</p>'))
->send();
return Base::retSuccess('成功发送');
} catch (\Exception $e) {
} catch (\Throwable $e) {
// 一般是请求超时
if (str_contains($e->getMessage(), "Timed Out")) {
return Base::retError("language.TimedOut");

View File

@ -46,7 +46,7 @@ class AbstractModel extends Model
{
try {
return $this->save();
} catch (\Exception $e) {
} catch (\Throwable) {
return false;
}
}

View File

@ -7,12 +7,9 @@ use App\Module\Base;
use App\Tasks\PushTask;
use Arr;
use Carbon\Carbon;
use Config;
use DB;
use Exception;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Database\Eloquent\SoftDeletes;
use Mail;
use Request;
/**
@ -1245,7 +1242,7 @@ class ProjectTask extends AbstractModel
//
try {
$project = Project::userProject($task->project_id);
} catch (Exception $e) {
} catch (\Throwable $e) {
if ($task->owner === null) {
throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002);
}

View File

@ -6,7 +6,6 @@ use App\Exceptions\ApiException;
use App\Models\Setting;
use App\Models\Tmp;
use Cache;
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Redirect;
@ -285,7 +284,7 @@ class Base
{
try {
Storage::makeDirectory($path);
} catch (Exception $e) {
} catch (\Throwable $e) {
}
if (!file_exists($path)) {
self::makeDir(dirname($path));
@ -486,7 +485,7 @@ class Base
try {
$array = json_decode($string, true);
return is_array($array) ? $array : [];
} catch (Exception $e) {
} catch (\Throwable) {
return [];
}
}
@ -504,7 +503,7 @@ class Base
}
try {
return json_encode($array, $options);
} catch (Exception $e) {
} catch (\Throwable) {
return '';
}
}
@ -2356,7 +2355,7 @@ class Base
if ($param['size'] > 0 && $fileSize > $param['size'] * 1024) {
return Base::retError('文件大小超限,最大限制:' . $param['size'] . 'KB');
}
} catch (Exception $e) {
} catch (\Throwable) {
$fileSize = 0;
}
$scaleName = "";
@ -2613,7 +2612,7 @@ class Base
try {
$white = imagecolorallocate($dst, 255, 255, 255);
imagefill($dst, 0, 0, $white);
} catch (Exception $e) {
} catch (\Throwable) {
}
if (function_exists('imagecopyresampled')) {

View File

@ -2,8 +2,6 @@
namespace App\Module;
use Exception;
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
class Ihttp
@ -88,7 +86,7 @@ class Ihttp
return Base::retError($error);
} else {
if ($isGb2312) {
try { $data = iconv('GB2312', 'UTF-8', $data); }catch (Exception $e) { }
try { $data = iconv('GB2312', 'UTF-8', $data); }catch (\Throwable) { }
}
$response = self::ihttp_response_parse($data);
Base::addLog([
@ -148,7 +146,7 @@ class Ihttp
$content .= fgets($fp, 512);
fclose($fp);
if ($isGb2312) {
try { $content = iconv('GB2312', 'UTF-8', $content); }catch (Exception $e) { }
try { $content = iconv('GB2312', 'UTF-8', $content); }catch (\Throwable) { }
}
$response = self::ihttp_response_parse($content, true);
Base::addLog([

View File

@ -27,7 +27,7 @@ abstract class AbstractTask extends Task
{
try {
$this->start();
} catch (\Exception $e) {
} catch (\Throwable $e) {
$this->info($e);
$this->failed($e);
}

View File

@ -172,7 +172,7 @@ class PushTask extends AbstractTask
try {
$swoole->push($fid, Base::array2json($msg));
$tmpMsgId > 0 && WebSocketTmpMsg::whereId($tmpMsgId)->update(['send' => 1]);
} catch (\Exception $e) {
} catch (\Throwable) {
}
}