Perbaikan handle error dawai dan webhook sementara
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user