Skip to content

Commit e6cfd69

Browse files
committed
Add ProcessErrors trait and add a try catch block to call billingo api endpoint
1 parent 6c26c87 commit e6cfd69

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Services/BillingoApiV3Service.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
namespace Deviddev\BillingoApiV3Wrapper\Services;
44

55
use Exception;
6+
use Deviddev\BillingoApiV3Wrapper\Traits\ProcessErrorsTrait;
67
use Illuminate\Support\Arr;
78
use Swagger\Client\Configuration as SwaggerConfig;
89

910
class BillingoApiV3Service
1011
{
1112

13+
use ProcessErrorsTrait;
14+
1215
/**
1316
* Store called api instance
1417
*
@@ -112,14 +115,19 @@ protected function classExists(string $className): void
112115
*/
113116
protected function createResponse(string $methodName, array $params, bool $methodSuffix = false, bool $customResponse = false)
114117
{
115-
$this->response =
116-
$customResponse ?: \call_user_func_array(
117-
array(
118-
$this->api,
119-
$this->setMethodName($methodName, $methodSuffix)
120-
),
121-
$params
122-
);
118+
try {
119+
$this->response =
120+
$customResponse ?: \call_user_func_array(
121+
array(
122+
$this->api,
123+
$this->setMethodName($methodName, $methodSuffix)
124+
),
125+
$params
126+
);
127+
} catch (\Throwable $th) {
128+
echo ($this->error($th->getMessage())->getJson());
129+
exit;
130+
}
123131

124132
$this->setResponse();
125133
}

0 commit comments

Comments
 (0)