mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-06 23:58:35 +00:00
Send extra request headers and throw PreconditionFailedException on 412
This commit is contained in:
5 files changed
+164
-18
No files matched your search
@@ -28,10 +28,16 @@ class ApiException extends ResourceException
|
||||
public static function fromResult(Result $result): static
|
||||
{
|
||||
$body = is_object($result->data) ? $result->data : null;
|
||||
$status = $result->response()?->getStatusCode() ?? 0;
|
||||
|
||||
// a failed conditional write; subclasses (CollectionException) keep their own type
|
||||
if ($status === 412 && static::class === self::class) {
|
||||
return PreconditionFailedException::fromResult($result);
|
||||
}
|
||||
|
||||
return new static(
|
||||
rtrim((string) ($body->message ?? $result->error()), '.'),
|
||||
$result->response()?->getStatusCode() ?? 0,
|
||||
$status,
|
||||
$body->error ?? null,
|
||||
$result->exception,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user