refactor: 规范Expection处理

This commit is contained in:
xboard
2023-12-04 20:40:49 +08:00
parent aa0fe64afe
commit 0ab7dee52d
65 changed files with 625 additions and 362 deletions
+3 -2
View File
@@ -3,6 +3,7 @@
namespace App\Services;
use App\Exceptions\ApiException;
use App\Models\Payment;
class PaymentService
@@ -16,7 +17,7 @@ class PaymentService
{
$this->method = $method;
$this->class = '\\App\\Payments\\' . $this->method;
if (!class_exists($this->class)) abort(500, 'gate is not found');
if (!class_exists($this->class)) throw new ApiException(500, 'gate is not found');
if ($id) $payment = Payment::find($id)->toArray();
if ($uuid) $payment = Payment::where('uuid', $uuid)->first()->toArray();
$this->config = [];
@@ -32,7 +33,7 @@ class PaymentService
public function notify($params)
{
if (!$this->config['enable']) abort(500, 'gate is not enable');
if (!$this->config['enable']) throw new ApiException(500, 'gate is not enable');
return $this->payment->notify($params);
}