Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293279

JSON and other serialization formats now handle non-4xx exceptions

$
0
0

Problem/Motivation

Despite claims to the contrary in various code snippets in the exception handling system, non-HTML requests to Drupal aren't that rare, anymore. Modules such as JSON-RPC and Simple OAuth work almost entirely over a JSON, for instance, but exceptions thrown while handling their routes many times come back as HTML.

I am working on getting exceptions thrown during Simple OAuth's processing (e.g., with an extension grant type) and even after adding a default _format: 'json' notation in the route's requirements, I still get HTML error pages.

This is because ExceptionJsonSubscriber and Serialization module's DefaultExceptionSubscriber (which overrides the former, if the module is enabled) both only explicitly handle 4xx.

JSON:API has its own DefaultExceptionSubscriber implementation which does also handle 5xx. I propose extracting this logic to the above two other handlers, so we can get mostly automatic exception handling on non-HTML routes.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293279

Trending Articles