Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This is very much a work in progress, built on top of #847 to generalize the way error handling is done. This allow to move the error handling out of the request processing to separate the error logic of the request logic. This also ensure that the error management is consistent across all requests.
This PR uses the decorator pattern (sorry if this is not the way to do in Perl, coming from Python that was what makes the more sense to me) and this logic could be extended to other common operation. (I included a commented example of how params validation could be achieved this way but this requires the support of custom error code in the JSON RPC module to be actually implemented.)
If you think this could be an improvement I can finish this work.
Relevant changes: https://github.com/zonemaster/zonemaster-backend/pull/848/files#diff-f159417cb7e91c84742d1cb44858b1eed39152de169ecc78fa6677fe879ac1b2R64-R124
Context
TODO
Changes
TODO
How to test this PR
TODO