Page MenuHomePhabricator

Provide a standardized way to add warnings to a REST API response
Open, Needs TriagePublic

Description

The action API has a setWarning method that can be used to add non-fatal warnings to the result. This is currently not possible in the REST API, where you can only display fatal errors (by throwing HttpException). This is problematic because handlers may end up implementing warnings differently: for instance, one could use a warnings property in the result, another could use warning, one could put them together with the response data, another could introduce a different top-level structure ({"result": (data that you'd see when the operation is successful), "warnings": (list of warnings)}, etc. I think it would be useful to have some methods in ResponseFactory for warnings, which would also be responsible for l10n (via formatMessage).