Merge pull request 'Perbaikan handle error dawai dan webhook sementara' (#96) from development into main
Reviewed-on: #96
This commit was merged in pull request #96.
This commit is contained in:
@@ -9,8 +9,10 @@ use Carbon\Carbon;
|
|||||||
use Error;
|
use Error;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
use GuzzleHttp\Exception\ServerException;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class DawaiService
|
class DawaiService
|
||||||
@@ -371,8 +373,16 @@ class DawaiService
|
|||||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
} catch (ServerException $th) {
|
||||||
|
$body = (string) $th->getResponse()->getBody();
|
||||||
|
$penyebab = preg_match('/\b\w*(?:Error|Exception):[^\r\n<]+/', html_entity_decode($body), $match)
|
||||||
|
? trim($match[0])
|
||||||
|
: Str::limit(trim(strip_tags($body)), 200);
|
||||||
|
|
||||||
|
Log::error('DAWAI : listStatusPresensi gagal - server DAWAI error (HTTP '.$th->getResponse()->getStatusCode().') bukan dari Verifikator, perbaiki di sisi DAWAI. Penyebab: '.$penyebab);
|
||||||
|
throw new Error($th->getMessage(), 500);
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
Log::error('DAWAI : '.$th->getMessage());
|
Log::error('DAWAI : listStatusPresensi gagal - '.$th->getMessage());
|
||||||
throw new Error($th->getMessage(), 500);
|
throw new Error($th->getMessage(), 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,27 +24,28 @@ class VerifikatorWebhookService
|
|||||||
|
|
||||||
public function kirimIzin(PengajuanPresensi $pengajuan, string $status, ?string $alasan = null): bool
|
public function kirimIzin(PengajuanPresensi $pengajuan, string $status, ?string $alasan = null): bool
|
||||||
{
|
{
|
||||||
try {
|
// Webhook Verifikator dinonaktifkan sementara.
|
||||||
$response = Http::timeout(5)
|
// try {
|
||||||
->post(self::URL, [
|
// $response = Http::timeout(5)
|
||||||
'jenis' => 'izin',
|
// ->post(self::URL, [
|
||||||
'nip' => $pengajuan->nip,
|
// 'jenis' => 'izin',
|
||||||
'tanggal' => Carbon::parse($pengajuan->tanggal_mulai)->format('Y-m-d'),
|
// 'nip' => $pengajuan->nip,
|
||||||
'kategori' => $this->slugKategori($pengajuan->getRawOriginal('kategori')),
|
// 'tanggal' => Carbon::parse($pengajuan->tanggal_mulai)->format('Y-m-d'),
|
||||||
'status' => $status,
|
// 'kategori' => $this->slugKategori($pengajuan->getRawOriginal('kategori')),
|
||||||
'alasan' => $alasan ?? '',
|
// 'status' => $status,
|
||||||
]);
|
// 'alasan' => $alasan ?? '',
|
||||||
|
// ]);
|
||||||
if ($response->successful()) {
|
//
|
||||||
Log::info("Webhook Verifikator berhasil: $pengajuan->nip ($status)");
|
// if ($response->successful()) {
|
||||||
|
// Log::info("Webhook Verifikator berhasil: $pengajuan->nip ($status)");
|
||||||
return true;
|
//
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
Log::warning("Webhook Verifikator gagal: $pengajuan->nip ($status) - HTTP {$response->status()}");
|
//
|
||||||
} catch (Throwable $th) {
|
// Log::warning("Webhook Verifikator gagal: $pengajuan->nip ($status) - HTTP {$response->status()}");
|
||||||
Log::error("Webhook Verifikator error: $pengajuan->nip ($status) - ".$th->getMessage());
|
// } catch (Throwable $th) {
|
||||||
}
|
// Log::error("Webhook Verifikator error: $pengajuan->nip ($status) - ".$th->getMessage());
|
||||||
|
// }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user