Skip to content

Commit

Permalink
Merge pull request #34 from doofinder/add-type-already-exists-error
Browse files Browse the repository at this point in the history
Adds TypeAlreadyExistsError
  • Loading branch information
carlosescri authored Jun 13, 2018
2 parents e443fb8 + 4a2d6cd commit 462ac5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Management/Errors/TypeAlreadyExists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace Doofinder\Api\Management\Errors;

class TypeAlreadyExists extends \Exception {}
10 changes: 7 additions & 3 deletions src/Management/Errors/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Doofinder\Api\Management\Errors;

use Doofinder\Api\Management\Errors\BadRequest;
use Doofinder\Api\Management\Errors\NotAllowed;
use Doofinder\Api\Management\Errors\NotFound;
use Doofinder\Api\Management\Errors\BadRequest;
use Doofinder\Api\Management\Errors\ThrottledResponse;
use Doofinder\Api\Management\Errors\QuotaExhausted;
use Doofinder\Api\Management\Errors\ThrottledResponse;
use Doofinder\Api\Management\Errors\TypeAlreadyExists;
use Doofinder\Api\Management\Errors\WrongResponse;


Expand All @@ -20,8 +21,11 @@ public static function handleErrors($statusCode, $response) {
case 404:
return new NotFound("Not Found: ".Utils::readError($response));
case 409:
if (preg_match('/indexing.*progress/i', $response) == 1) { // trying to index while indexing in progress
if (preg_match('/indexing.*progress/i', $response) == 1) {
// The search engine is locked
return new IndexingInProgress(Utils::readError($response));
} else if (preg_match('/type.*already created/i', $response) == 1) {
return new TypeAlreadyExists(Utils::readError($response));
} else {
return new BadRequest("Request conflict: ".Utils::readError($response)); // trying to post with an already used id
}
Expand Down

0 comments on commit 462ac5c

Please sign in to comment.