zonemaster-engine icon indicating copy to clipboard operation
zonemaster-engine copied to clipboard

Make it possible to distinguish between user errors and API contract violations

Open mattias-p opened this issue 7 months ago • 0 comments

The $profile->set() method raises exceptions for both illegal profile property values and API contract violations. In an application we want to handle these to cases differently. Errors resulting from illegal property values should be reported back to the user (in case the value was provided by a user), but other errors should be logged as internal errors.

Today code that calls $profile->set() doesn't have a good way to distinguish between user errors and internal errors.

The $profile-set() API should be updated with a robust way to distinguish validation errors from API contract errors.

Since this allows callers to do something new this change is at least minor. One way to implement it in a non-breaking way would be to wrap the API contract violation exceptions in a special error class with the "" operator overloaded.

mattias-p avatar Jul 22 '24 12:07 mattias-p