Integrasi Login dan menu Dasar SIAKAD Operator dan Mahasiswa
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Database\QueryException;
|
||||
use PDOException;
|
||||
use Throwable;
|
||||
|
||||
/** Pengenal galat koneksi DB (SQLSTATE kelas 08), mis. server DB lama tidak terjangkau dari luar jaringan UNTAN. */
|
||||
final class DatabaseUnreachable
|
||||
{
|
||||
public const string MESSAGE = 'Tidak dapat menghubungkan ke server, silakan ganti menggunakan jaringan UNTAN.';
|
||||
|
||||
public static function matches(Throwable $e): bool
|
||||
{
|
||||
if (! $e instanceof QueryException && ! $e instanceof PDOException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Saat membuka koneksi, kode PDO berisi kode driver (mis. 7); SQLSTATE hanya ada di awal pesan.
|
||||
$pdo = $e instanceof QueryException ? ($e->getPrevious() ?? $e) : $e;
|
||||
|
||||
return str_starts_with((string) $e->getCode(), '08')
|
||||
|| str_starts_with($pdo->getMessage(), 'SQLSTATE[08');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user