Repository navigation
feat(exception): add InvalidDataThrowable marker interface - #6
Conversation
Marks exceptions caused by invalid data supplied by the caller (as opposed to a failure of the server), so consumers such as protocol handlers can tell "do not retry this item" from "try again later" without depending on the concrete exception classes of an application. Same pattern as PermissionDeniedThrowable. First implementer is Turba_Exception_InvalidAttribute (horde/turba#73).
|
I am not against it but I wonder if we are not better off basing this on either InvalidArgumentException or UnexpectedValueException (a runtime exception which says "this value doesn't fit the constraints" |
|
Agreed that The reason for a marker interface instead of a base class is The two are not exclusive: once the Turba exceptions move to |
Summary
Horde\Exception\InvalidDataThrowable(extendsHordeThrowable), following thePermissionDeniedThrowablepattern.Motivation
Applications throw their own exception classes when a caller supplies data they cannot store (a Turba attribute over its configured
maxlength, for example). Protocol handlers in other packages —Horde_Core_ActiveSync_Driverin this case — need to distinguish "the client's data is invalid, do not retry" from "the server failed, try again" without depending onTurba_*classes. A framework-level marker interface keeps that check implementation-agnostic.Context: horde/turba#73 (attribute constraints only enforced in the web form; ActiveSync clients resend a rejected contact forever because it is reported as a server error).
Changes
src/InvalidDataThrowable.php— empty marker interface with docblock describing the contract (the exception message describes the invalid input; retrying with the same input will fail again).Related PRs
Turba_Exception_InvalidAttribute implements InvalidDataThrowableInvalidDataThrowableto ActiveSyncSTATUS_INVALIDNote for release: adding the interface is a minor-version feature; the dependent packages currently require
horde/exception: ^3 || dev-FRAMEWORK_6_0and will need^3.1(or whichever version ships this) once released.Test plan
php -l src/InvalidDataThrowable.phpTurba_Exception_InvalidAttribute instanceof InvalidDataThrowable)