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 { try {
Madzipper::make($zipPath)->add($xlsPath)->close(); Madzipper::make($zipPath)->add($xlsPath)->close();
} catch (\Exception) { } catch (\Throwable) {
} }
// //
if (file_exists($zipPath)) { if (file_exists($zipPath)) {
@ -1386,7 +1386,7 @@ class ProjectController extends AbstractController
// //
try { try {
ProjectTask::userTask($file->task_id, null); ProjectTask::userTask($file->task_id, null);
} catch (\Exception $e) { } catch (\Throwable $e) {
abort(403, $e->getMessage() ?: "This file not support download."); 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>')) ->html('<p>收到此电子邮件意味着您的邮箱配置正确。</p><p>Receiving this email means that your mailbox is configured correctly.</p>'))
->send(); ->send();
return Base::retSuccess('成功发送'); return Base::retSuccess('成功发送');
} catch (\Exception $e) { } catch (\Throwable $e) {
// 一般是请求超时 // 一般是请求超时
if (str_contains($e->getMessage(), "Timed Out")) { if (str_contains($e->getMessage(), "Timed Out")) {
return Base::retError("language.TimedOut"); return Base::retError("language.TimedOut");

View File

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

View File

@ -7,12 +7,9 @@ use App\Module\Base;
use App\Tasks\PushTask; use App\Tasks\PushTask;
use Arr; use Arr;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use DB; use DB;
use Exception;
use Hhxsv5\LaravelS\Swoole\Task\Task; use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Mail;
use Request; use Request;
/** /**
@ -1245,7 +1242,7 @@ class ProjectTask extends AbstractModel
// //
try { try {
$project = Project::userProject($task->project_id); $project = Project::userProject($task->project_id);
} catch (Exception $e) { } catch (\Throwable $e) {
if ($task->owner === null) { if ($task->owner === null) {
throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002); 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\Setting;
use App\Models\Tmp; use App\Models\Tmp;
use Cache; use Cache;
use Exception;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Redirect; use Redirect;
@ -285,7 +284,7 @@ class Base
{ {
try { try {
Storage::makeDirectory($path); Storage::makeDirectory($path);
} catch (Exception $e) { } catch (\Throwable $e) {
} }
if (!file_exists($path)) { if (!file_exists($path)) {
self::makeDir(dirname($path)); self::makeDir(dirname($path));
@ -486,7 +485,7 @@ class Base
try { try {
$array = json_decode($string, true); $array = json_decode($string, true);
return is_array($array) ? $array : []; return is_array($array) ? $array : [];
} catch (Exception $e) { } catch (\Throwable) {
return []; return [];
} }
} }
@ -504,7 +503,7 @@ class Base
} }
try { try {
return json_encode($array, $options); return json_encode($array, $options);
} catch (Exception $e) { } catch (\Throwable) {
return ''; return '';
} }
} }
@ -2356,7 +2355,7 @@ class Base
if ($param['size'] > 0 && $fileSize > $param['size'] * 1024) { if ($param['size'] > 0 && $fileSize > $param['size'] * 1024) {
return Base::retError('文件大小超限,最大限制:' . $param['size'] . 'KB'); return Base::retError('文件大小超限,最大限制:' . $param['size'] . 'KB');
} }
} catch (Exception $e) { } catch (\Throwable) {
$fileSize = 0; $fileSize = 0;
} }
$scaleName = ""; $scaleName = "";
@ -2613,7 +2612,7 @@ class Base
try { try {
$white = imagecolorallocate($dst, 255, 255, 255); $white = imagecolorallocate($dst, 255, 255, 255);
imagefill($dst, 0, 0, $white); imagefill($dst, 0, 0, $white);
} catch (Exception $e) { } catch (\Throwable) {
} }
if (function_exists('imagecopyresampled')) { if (function_exists('imagecopyresampled')) {

View File

@ -2,8 +2,6 @@
namespace App\Module; namespace App\Module;
use Exception;
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); @error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
class Ihttp class Ihttp
@ -88,7 +86,7 @@ class Ihttp
return Base::retError($error); return Base::retError($error);
} else { } else {
if ($isGb2312) { 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); $response = self::ihttp_response_parse($data);
Base::addLog([ Base::addLog([
@ -148,7 +146,7 @@ class Ihttp
$content .= fgets($fp, 512); $content .= fgets($fp, 512);
fclose($fp); fclose($fp);
if ($isGb2312) { 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); $response = self::ihttp_response_parse($content, true);
Base::addLog([ Base::addLog([

View File

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

View File

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