feat(form-builder): exception hierarchy for binding-apply pipeline
Per RFC-WS-6 §Q3 v1.3 addition 2 (binding hierarchy) + §Q2 (invariant exception).
- Refactored FormBindingApplicatorException from concrete final to abstract
base. Constructor (submissionId, message, previous?) preserves submissionId
as a public readonly property so D2's outer-transaction handler can write
it structurally to form_submission_action_failures.context JSON without
regex-parsing the message. Replaced public-readonly reasonCode property
with abstract reasonCode(): string method.
- Added 3 reason-coded subclasses:
- FormBindingSchemaConfigException -> 'schema_config_error' (422)
- FormBindingInfraException -> 'temporary_error' (503, NOT final because
Timeout extends it)
- FormBindingDataIntegrityException -> 'data_integrity_error' (422)
- Added FormBindingApplicatorTimeoutException extending FormBindingInfraException
(timeout = temporary infra issue from user perspective; reasonCode inherited).
- Added IdentityMatchInvariantViolation as a sibling DomainException — NOT
in the FormBindingApplicatorException hierarchy because it's thrown
outside the binding-applicator pipeline.
- Migrated 3 existing throw sites in FormBindingApplicator::apply():
- 'no_transaction' -> FormBindingInfraException (developer-error wants
infra-triage workflow: GlitchTip alert + retry-after)
- 'no_schema' -> FormBindingSchemaConfigException
- 'unknown_purpose' -> FormBindingSchemaConfigException
- Updated FormBindingApplicatorIntegrationTest::test_no_transaction_guard_present
to assert against the new throw shape (FormBindingInfraException + new
message string) while preserving the test's intent (guard exists in source).
Wiring (deadline wrapper, classifier integration in listener catch +
retry-service recordFailure) lands in D2.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
28
api/app/Exceptions/FormBuilder/FormBindingInfraException.php
Normal file
28
api/app/Exceptions/FormBuilder/FormBindingInfraException.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exceptions\FormBuilder;
|
||||
|
||||
/**
|
||||
* Infrastructure issue during binding apply.
|
||||
*
|
||||
* Examples: database connection lost, lock-for-update wait exceeded,
|
||||
* race condition surfaced as a constraint violation that retry would
|
||||
* resolve, applicator invoked outside a DB transaction (developer-error
|
||||
* surfacing as infra-triage workflow).
|
||||
*
|
||||
* Maps to HTTP 503, failure_response_code='temporary_error'.
|
||||
* User-facing copy: "Temporary issue, please try again." with retry-after.
|
||||
*
|
||||
* NOT final — FormBindingApplicatorTimeoutException extends this class.
|
||||
*
|
||||
* Per RFC-WS-6 §Q3 v1.3 addition 2.
|
||||
*/
|
||||
class FormBindingInfraException extends FormBindingApplicatorException
|
||||
{
|
||||
public function reasonCode(): string
|
||||
{
|
||||
return 'temporary_error';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user