mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
refactor: 规范Expection处理
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user