add error page

This commit is contained in:
KhatamNugraha
2024-06-24 12:03:06 +07:00
parent 56e599438e
commit 044c686477
4 changed files with 105 additions and 43 deletions

View File

@ -34,6 +34,7 @@ use Modules\Konfirmasibank\Http\Requests\Fasilitas\StoreFasilitasRequest;
use Akaunting\Money\Currency;
use Akaunting\Money\Money;
use Illuminate\Validation\Rule;
use App\Exports\DataExport; // Sesuaikan dengan class export Anda
class KonfirmasiBankController extends Controller
{
@ -418,7 +419,6 @@ class KonfirmasiBankController extends Controller
}
}
// try {
foreach ($listAccount as $key1 => $account) {
@ -448,15 +448,8 @@ class KonfirmasiBankController extends Controller
$DataDepo = [];
try {
$Deposito = $Account->getDepo($request['cusNo'], $arrAccount, $dateCoreDepo)->get();
} catch (\Illuminate\Database\QueryException $e) {
$errorCode = $e->errorInfo[1];
if ($errorCode == 1205) { // 1205 adalah kode error untuk Lock wait timeout exceeded; try restarting transaction
// Lakukan sesuatu jika terjadi timeout
return response()->json(['error' => 'Database timeout, please try again later'], 503);
}
// Handle error lainnya
return response()->json(['error' => 'Database error'], 500);
} catch (Exception $e) {
return redirect()->route('konfirmasibank.timeout');
}
foreach ($Deposito as $keyDep => $depo) {
@ -478,13 +471,7 @@ class KonfirmasiBankController extends Controller
$Arrangement = $Account->getPinjaman($request['cusNo'], $dateCoreAccount)->get();
} catch (\Illuminate\Database\QueryException $e) {
$errorCode = $e->errorInfo[1];
if ($errorCode == 1205) { // 1205 adalah kode error untuk Lock wait timeout exceeded; try restarting transaction
// Lakukan sesuatu jika terjadi timeout
return response()->json(['error' => 'Database timeout, please try again later'], 503);
}
// Handle error lainnya
return response()->json(['error' => 'Database error'], 500);
return redirect()->route('konfirmasibank.timeout');
}
foreach ($Arrangement as $key2 => $pinjaman) {
@ -507,21 +494,13 @@ class KonfirmasiBankController extends Controller
$listAccountRK = $Account->getAccountRK($arrAccount, $dateCoreAccount)->get();
} catch (\Illuminate\Database\QueryException $e) {
$errorCode = $e->errorInfo[1];
if ($errorCode == 1205) { // 1205 adalah kode error untuk Lock wait timeout exceeded; try restarting transaction
// Lakukan sesuatu jika terjadi timeout
return response()->json(['error' => 'Database timeout, please try again later'], 503);
}
// Handle error lainnya
return response()->json(['error' => 'Database error'], 500);
return redirect()->route('konfirmasibank.timeout');
}
foreach ($listAccountRK as $rk => $valRk) {
$DataRK[$rk]['ACCOUNT_NUMBER'] = $valRk->ACCOUNT_NUMBER;
// $DataRK[$rk]['OPENING_DATE'] = $valRk->OPENING_DATE;
$DataRK[$rk]['BATCH_DATE'] = $valRk->BATCH_DATE;
// $DataRK[$rk]['CUSTOMER_NO'] = $valRk->CUSTOMER_NO;
$DataRK[$rk]['SHORT_NAME'] = $valRk->PRODUCT_LOAN;
$DataRK[$rk]['CURRENCY'] = $valRk->LOAN_CCY;
$DataRK[$rk]['PRODUCT'] = $valRk->PRODUCT_LOAN;
@ -534,17 +513,11 @@ class KonfirmasiBankController extends Controller
}
try {
try {
$fasilitas = Fasilitas::where('nomor_cif', $request['cusNo'])->where('status', 1)->get();
} catch (\Illuminate\Database\QueryException $e) {
$errorCode = $e->errorInfo[1];
if ($errorCode == 1205) { // 1205 adalah kode error untuk Lock wait timeout exceeded; try restarting transaction
// Lakukan sesuatu jika terjadi timeout
return response()->json(['error' => 'Database timeout, please try again later'], 503);
}
// Handle error lainnya
return response()->json(['error' => 'Database error'], 500);
return redirect()->route('konfirmasibank.timeout');
}
foreach ($fasilitas as $key3 => $val3) {
@ -564,13 +537,7 @@ class KonfirmasiBankController extends Controller
$ListAnjak = $Account->getAccountAnjak($rekEscrow, $dateCoreAccount)->get();
} catch (\Illuminate\Database\QueryException $e) {
$errorCode = $e->errorInfo[1];
if ($errorCode == 1205) { // 1205 adalah kode error untuk Lock wait timeout exceeded; try restarting transaction
// Lakukan sesuatu jika terjadi timeout
return response()->json(['error' => 'Database timeout, please try again later'], 503);
}
// Handle error lainnya
return response()->json(['error' => 'Database error'], 500);
return redirect()->route('konfirmasibank.timeout');
}
$totalOutstanding = $ListAnjak->sum('OUTSTANDING') != null ? number_format(abs($ListAnjak->sum('OUTSTANDING')), 2, ',', '.') : 'NIHIL';
@ -883,5 +850,9 @@ class KonfirmasiBankController extends Controller
}
public function timeout(){
return view('konfirmasibank::errors.404');
}
}