Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Zarubin committed Jun 27, 2022
1 parent 1a35d89 commit e107e8c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use nikserg\ItcomPublicApi\exceptions\PublicApiException;
use nikserg\ItcomPublicApi\exceptions\PublicApiMalformedRequestException;
use nikserg\ItcomPublicApi\exceptions\PublicApiMalformedRequestValidationException;
use nikserg\ItcomPublicApi\exceptions\PublicApiNotFoundException;
use nikserg\ItcomPublicApi\exceptions\WrongCodeException;
use nikserg\ItcomPublicApi\models\request\CryptoProvider;
use nikserg\ItcomPublicApi\models\request\LegalForm;
Expand Down Expand Up @@ -488,6 +489,9 @@ protected function checkError(ResponseInterface $response): ResponseInterface
if (isset($json['error'])) {
$errorClass = PublicApiException::class;
switch ($json['error']['type']) {
case 'NotFoundException':
$errorClass = PublicApiNotFoundException::class;
break;
case 'PublicApiMalformedRequestException':
$errorClass = PublicApiMalformedRequestException::class;
break;
Expand Down
2 changes: 1 addition & 1 deletion exceptions/PublicApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function __construct(array $json, ?Throwable $previous = null)
$this->publicApiFile = $json['file'] ?? null;
$this->publicApiTrace = $json['trace'] ?? null;
$this->publicApiExceptionClass = $type;
parent::__construct($type . ': ' . $message, $code, $previous);
parent::__construct($type . ': ' . $message.'. Ошибка в CRM: '.print_r($json, true), $code, $previous);
}
}
10 changes: 10 additions & 0 deletions exceptions/PublicApiNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace nikserg\ItcomPublicApi\exceptions;

/**
* Сущность не найдена на стороне CRM
*/
class PublicApiNotFoundException extends PublicApiException
{
}

0 comments on commit e107e8c

Please sign in to comment.