Add ConflictException
This commit is contained in:
parent
5908568877
commit
1359721d67
|
@ -16,6 +16,7 @@ use Zoomyboy\LaravelNami\Data\Member;
|
||||||
use Zoomyboy\LaravelNami\Data\MemberEntry;
|
use Zoomyboy\LaravelNami\Data\MemberEntry;
|
||||||
use Zoomyboy\LaravelNami\Data\Membership;
|
use Zoomyboy\LaravelNami\Data\Membership;
|
||||||
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
||||||
|
use Zoomyboy\LaravelNami\Exceptions\ConflictException;
|
||||||
use Zoomyboy\LaravelNami\Exceptions\HttpException;
|
use Zoomyboy\LaravelNami\Exceptions\HttpException;
|
||||||
use Zoomyboy\LaravelNami\Exceptions\MemberDataCorruptedException;
|
use Zoomyboy\LaravelNami\Exceptions\MemberDataCorruptedException;
|
||||||
use Zoomyboy\LaravelNami\Exceptions\NoJsonReceivedException;
|
use Zoomyboy\LaravelNami\Exceptions\NoJsonReceivedException;
|
||||||
|
@ -126,9 +127,7 @@ class Api
|
||||||
$payload['kontoverbindung'] = json_encode(data_get($payload, 'kontoverbindung', []));
|
$payload['kontoverbindung'] = json_encode(data_get($payload, 'kontoverbindung', []));
|
||||||
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->groupId.'/'.$member->id;
|
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->groupId.'/'.$member->id;
|
||||||
$response = $this->http()->put($url, $payload);
|
$response = $this->http()->put($url, $payload);
|
||||||
if (true !== data_get($response->json(), 'success')) {
|
$this->assertOk($response, $url, 'Update failed');
|
||||||
$this->exception(NotSuccessfulException::class, 'Update failed', $url, $response->json(), $member->toNami());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response->json()['data']['id'];
|
return $response->json()['data']['id'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -480,6 +479,10 @@ class Api
|
||||||
$this->exception(RightException::class, $error, $url, $response->json());
|
$this->exception(RightException::class, $error, $url, $response->json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data_get($response, 'message') && Str::contains($response['message'], 'Der Datensatz wurde zwischenzeitlich verändert')) {
|
||||||
|
$this->exception(ConflictException::class, $error, $url, $response->json());
|
||||||
|
}
|
||||||
|
|
||||||
if (false === $response['success']) {
|
if (false === $response['success']) {
|
||||||
$this->exception(NotSuccessfulException::class, $error, $url, $response->json());
|
$this->exception(NotSuccessfulException::class, $error, $url, $response->json());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zoomyboy\LaravelNami\Exceptions;
|
||||||
|
|
||||||
|
class ConflictException extends HttpException
|
||||||
|
{
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ namespace Zoomyboy\LaravelNami\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
abstract class HttpException extends Exception
|
abstract class HttpException extends Exception
|
||||||
|
@ -54,9 +53,9 @@ abstract class HttpException extends Exception
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isConflict(): bool
|
public function render(): void
|
||||||
{
|
{
|
||||||
return Str::contains(data_get($this->response, 'message'), 'Der Datensatz wurde zwischenzeitlich verändert');
|
throw ValidationException::withMessages(['id' => 'Unbekannter Fehler']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function report(): void
|
public function report(): void
|
||||||
|
@ -68,11 +67,6 @@ abstract class HttpException extends Exception
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(): void
|
|
||||||
{
|
|
||||||
throw ValidationException::withMessages(['id' => 'Unbekannter Fehler']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function outputToConsole(Command $command): void
|
public function outputToConsole(Command $command): void
|
||||||
{
|
{
|
||||||
$command->info('Request URL: '.$this->requestUrl);
|
$command->info('Request URL: '.$this->requestUrl);
|
||||||
|
|
Loading…
Reference in New Issue