错误处理

This commit is contained in:
iVampireSP.com 2022-12-06 17:35:57 +08:00
parent 2336eb5754
commit 13730c5dea
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 75 additions and 65 deletions

View File

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Admin;
use App\Exceptions\EmqxSupportException;
use App\Http\Controllers\Controller;
use App\Support\EmqxSupport;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
@ -15,11 +17,15 @@ public function index(Request $request)
{
$emqx = new EmqxSupport();
try {
$clients = $emqx->clients([
'clientid' => $request->client_id,
'username' => $request->username,
'page' => $request->page,
]);
} catch (EmqxSupportException|ConnectionException $e) {
return back()->with('error', $e->getMessage());
}
// dd($clients);
return view('admin.device.index', compact('clients'));

View File

@ -35,6 +35,7 @@
</thead>
<tbody>
@if(isset($clients))
@foreach($clients['data'] as $c)
<tr>
<td>
@ -81,9 +82,11 @@
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
@if(isset($clients))
<div class="d-none flex-sm-fill d-sm-flex align-items-sm-center justify-content-sm-end">
<div>
<ul class="pagination">
@ -101,5 +104,6 @@
</ul>
</div>
</div>
@endif
@endsection