Skip to content

Commit

Permalink
Merge pull request #14 from achmadhadikurnia/main
Browse files Browse the repository at this point in the history
feat: add log for failed post riwayat
  • Loading branch information
achmadhadikurnia authored Mar 8, 2024
2 parents 8ef6f75 + 7029d9a commit 56b82a0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Services/PostRiwayatBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Kanekescom\Siasn\Simpeg\Services;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;
use Kanekescom\Siasn\Simpeg\Exceptions\FailedPostRiwayatException;
use Kanekescom\Siasn\Simpeg\Facades\Simpeg;

Expand All @@ -22,6 +23,8 @@ class PostRiwayatBase

protected $success = false;

protected $message = null;

public function __construct(array $data, Model $record)
{
$this->data = $data;
Expand Down Expand Up @@ -51,9 +54,11 @@ public function send()
{
$this->response = Simpeg::{$this->pushMethod}($this->buildQuery());
$this->success = $this->response->object()->success;
$this->message = $this->response->object()->message;

if ($this->success === false) {
throw new FailedPostRiwayatException($this->response->object()->message);
throw new FailedPostRiwayatException($this->message);
Log::error($this->message);
}

return $this;
Expand Down

0 comments on commit 56b82a0

Please sign in to comment.