Perbaikan handle error dawai dan webhook sementara

This commit is contained in:
Ariyutta
2026-10-28 15:20:28 +07:00
parent 7b8d43ed9b
commit a9b173fb80
2 changed files with 33 additions and 22 deletions
+11 -1
View File
@@ -9,8 +9,10 @@ use Carbon\Carbon;
use Error;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Throwable;
class DawaiService
@@ -371,8 +373,16 @@ class DawaiService
$data = json_decode($response->getBody()->getContents(), true)['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) {
Log::error('DAWAI : '.$th->getMessage());
Log::error('DAWAI : listStatusPresensi gagal - '.$th->getMessage());
throw new Error($th->getMessage(), 500);
}
}