Skip to content

Commit 0f869ad

Browse files
committed
feat(exceptions): add GatewayException for HTTP gateway errors
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 2dafd79 commit 0f869ad

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/Exception/GatewayException.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
declare(strict_types=1);
7+
8+
namespace LibreCodeCoop\NfsePHP\Exception;
9+
10+
/**
11+
* Thrown when the SEFIN gateway responds with an HTTP error status (4xx/5xx).
12+
*
13+
* The upstream error payload is preserved to allow callers to surface
14+
* gateway-specific diagnostic information (e.g. fiscal rejection codes).
15+
*/
16+
class GatewayException extends NfseException
17+
{
18+
/**
19+
* @param array<string, mixed> $upstreamPayload Raw decoded response body from the gateway.
20+
*/
21+
public function __construct(
22+
string $message,
23+
public readonly NfseErrorCode $errorCode,
24+
public readonly int $httpStatus = 0,
25+
public readonly array $upstreamPayload = [],
26+
?\Throwable $previous = null,
27+
) {
28+
parent::__construct($message, 0, $previous);
29+
}
30+
}

0 commit comments

Comments
 (0)